On Sep 27, 2011, at 6:41 PM, William Squires wrote:

> Hi,
>  I have a need for a complex data-entry form (window). Some fields are 
> supposed to only accept alpha characters (upper or lower), some are supposed 
> to only take integers, others to only take floats (but no negative values 
> allowed). Is there a general way of validating the contents of a field before 
> it resigns first responder status? Even better, is there a way to encapsulate 
> that behavior in an NSTextField subclass so that I can make, say, an 
> AlphaOnlyTextField class, drag a (normal) NSTextField onto the window in IB, 
> then change it's super to "AlphaOnlyTextField", or some such? This way I can 
> save a lot of time, and will have a reusable control (sub)class that I can 
> then use in other projects!
>  I'm still using Xcode 3.somethingorother, and IB for my MacOS X/iOS work.
>  Here's the control flow I hope to tap into:
> 
> Control (an NSTextField) has focus (is first responder) - user types 
> something into the NSTextField
> User tabs (or shift-tabs) to the next control, or clicks the mouse on another 
> control
> NSTextField that currently has first responder status checks to see if it has 
> a delegate, and - if it does - does it respond to validate:? If so, the 
> delegate gets sent the validate: message which returns a BOOL.
> 

What about "validate<Key>:error", as described under 
"validateValue:forKey:error"? I've used that a 
lot._______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to