What's the best way to limit input on an NSTextField to numbers only? (newbie)
What's the best way to limit input on an NSTextField to numbers only? (newbie)
- Subject: What's the best way to limit input on an NSTextField to numbers only? (newbie)
- From: Rob Frohne <email@hidden>
- Date: Sun, 1 Sep 2002 22:58:21 -0700
Hi All,
I'd like to limit input into my NSMatrix of NSTextFields to be numbers
only, things like 3.2e5, or 5.5 or 9.99. I got a delegate that gets
run when the NSTextFields change, but the NSString I get isn't quite as
simple to process as just the individual keys that are being typed.
I've looked at NSScanner, and it looks like that might have some merit.
Is that the best way to handle this kind of thing?
Thanks,
Rob
P.S. Here is my present delegate:
- (void)controlTextDidChange:(NSNotification*)aNotification
{
// if (([[displayMatrix selectedCell] stringValue] < '1') ||
([[displayMatrix selectedCell] stringValue] > '9')) // This doesn't
work because we are getting a whole string instead of just an ASCII
char.
{
NSBeep();
}
}
--
Rob Frohne, Ph.D., P.E.
E.F. Cross School of Engineering
Walla Walla College
http://www.wwc.edu/~frohro/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.