home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula
/
nebula.bin
/
SourceCode
/
MiniExamples
/
FilterFunctions
/
SSTextField.m
< prev
next >
Wrap
Text File
|
1991-09-29
|
2KB
|
64 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 "SSTextField.h"
#import "SSTFCell.h"
#import <strings.h>
@implementation SSTextField
/* set the custom Cell class as the Cell class for this TextField class */
+ initialize
{
[super initialize];
[SSTextField setCellClass:[SSTFCell class]];
return self;
}
/* override to call endEditing: on the Cell so that the text filter function of
* the fieldEditor will be reset to the original.
*/
- textDidEnd:anObject endChar:(unsigned short)whyEnd
{
[[self cell] endEditing:anObject];
[super textDidEnd:anObject endChar:whyEnd];
return self;
}
/* override to check that when the user presses return to stop editing the
* field, the entry is complete and correct. Don't accept the value until it
* has the right length. Remember, the format of the entry has been validated
* by the text filter function so just check the length here.
*/
- textWillEnd:textObject
{
char *currVal;
/* get the current value in the DateTextField */
currVal = (char *)[self stringValue];
/* if the string is 11 chars long then, because it's been filtered, it
* must completely and correctly specify a date string. Else, the user
* has terminated the editing of the field before completing the SS.
* By returning nil, the SSTextField will remain the firstResponder
* and the user must finish entering the date.
*/
if (strlen(currVal) == 11) {
return nil;
} else {
[super textWillEnd:textObject];
return self;
}
}
@end