Re: restricting input to text field
Re: restricting input to text field
- Subject: Re: restricting input to text field
- From: "Paul J. Lucas" <email@hidden>
- Date: Sat, 8 Oct 2005 08:45:43 -0700 (PDT)
On Sat, 8 Oct 2005, Herbert wrote:
> In the codewarrior days, it was pretty easy to take the text input class and
> subclass it so you could restrict text entry on a per character basis (i.e.
> decimal only or even hex).
>
> Can this be done with the cocoa NSTextField class or perhaps the
> NSSecureTextField class?
After Googl'ing, the solution I came up with (for numeric-only
fields) was to subclass NSNumberFormatter and override
isPartialStringValid, then do:
[[myField cell] setFormatter:myFormatter];
In my case, I went further by auto-updating another field as the
user types in addition to validity checking.
- Paul
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden