Re: NSTextField input validation
Re: NSTextField input validation
- Subject: Re: NSTextField input validation
- From: Keary Suska <email@hidden>
- Date: Tue, 13 Jan 2009 09:23:11 -0700
On Jan 12, 2009, at 5:22 PM, Adam Venturella wrote:
So there we have it. Again this does do exactly what I want it to
do, if
the user tries to enter a letter or anything not a number, I get an
NSBeep(); It works if the operation is a paste operation or
initiated by a
keystroke.
My main question, am I doing the right thing by casting the NSText
into a
NSTextView, and is the NumberFormatter the best way to go in order
to test
for a valid number or should I go the NSScanner route?
Subclassing NSTextFieldCell seems a bit unnecessary--why not just set
the NSTextField delegate to one of your controllers? The whole -
setUpFieldEditorAttributes seems a bit kludgey to me (and possibly
prone to errors).
Also, I would use an NSCharacterSet (-characterIsMember:) instead of
NSFormatter or NSSCanner. Much more lightweight.
HTH,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden