home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula
/
nebula.bin
/
SourceCode
/
MiniExamples
/
FilterFunctions
/
FilterTextCell.m
< prev
next >
Wrap
Text File
|
1991-09-29
|
2KB
|
70 lines
/*
* You may freely copy, distribute and reuse the code
* in this example. NeXT disclaims any warranty of
* any kind, expressed or implied, as to its fitness
* for any particular use.
*
* Written by: Susan Rayl
*
* Created 21-Mar-91
*/
#import "FilterTextCell.h"
#import <appkit/Text.h>
@implementation FilterTextCell
/* initialize the newTextFilter instance variable to nil until an instance of a
* subclass of FilterTextCell fills in a value according to its requirements
*
* Note that this code is in the initialize method, not the initFrame: method.
* The initialize method initializes attributes of the class before it's ever used;
* that is, before any instances are ever created. Ìn this initialize method, the
* cell class of the SSTextField is being reset from the default TextFieldCell to
* a custom TextFieldCell class, SSTFCell. This must be done before any
* instances are created so that all instances will have the correct cell class.
* Remember, initialize is called before any instances of the class are created;
* initFrame: is called as each instance is created.
*/
- init
{
[super init];
newTextFilter = (NXTextFilterFunc)nil;
return self;
}
/* save original filter func and set the new one when the user selects the text
* in this Cell by TABbing into this TextField.
*/
- select:(const NXRect *)aRect inView:controlView editor:textObj delegate:anObject start:(int)selStart length:(int)selLength
{
[super select:aRect inView:controlView editor:textObj delegate:anObject start:selStart length:selLength];
oldTextFilter = [textObj textFilter];
[textObj setTextFilter:(NXTextFilterFunc)newTextFilter];
return self;
}
/* save original filter func and set the new one when the user selects the text
* in this Cell by clicking in this TextField.
*/
- edit:(const NXRect *)aRect inView:controlView editor:textObj delegate:anObject event:(NXEvent *)theEvent
{
[super edit:aRect inView:controlView editor:textObj delegate:anObject event:theEvent];
oldTextFilter = [textObj textFilter];
[textObj setTextFilter:(NXTextFilterFunc)newTextFilter];
return self;
}
/* reset the original filter func after the user is done */
- endEditing:anObject
{
[anObject setTextFilter:(NXTextFilterFunc)oldTextFilter];
[super endEditing:anObject];
return self;
}
@end