How can I forbid users to type numbers in a NSTextField ?
I’m currently using a custom NSFormatter showing a popup after the users typed the value, but how can I prevent the inserting right after typing instead ?
thanks
I’ve tried this and it almost work.. but if I type a number and then some letters i.e. “24jdf” the letters are still displayed (even if removed when the field looses focus).
- (BOOL)isPartialStringValid:(NSString *)partialString newEditingString:(NSString **)newString errorDescription:(NSString **)error
//- (BOOL)getObjectValue:(id *)obj forString:(NSString *)string errorDescription:(NSString **)error
{
if ([self numberFromString:partialString] == nil)
return NO;
return YES;
}
You’ll have to subclass your
NSFormatterand override the following method: