Re: NSNumberFormattter not working
Re: NSNumberFormattter not working
- Subject: Re: NSNumberFormattter not working
- From: Keary Suska <email@hidden>
- Date: Thu, 12 Jul 2007 09:48:00 -0600
- Thread-topic: NSNumberFormattter not working
on 7/12/07 8:59 AM, email@hidden purportedly said:
> Well I played around with a formatter in IB and apparently number
> formatters don't prevent alpha entry they only beep on completion to
> indicate that something is wrong.
>
> I must be "fighting the framework" here, as I can't believe that
> something so conceptually simple as restricting text input to only
> valid numeric characters, would require delegates or overriding the
> application's key handling mechanism. (Which is what several threads
> at CocoaDev suggested)
>
> I know the following NSTextField method doesn't exist, but is there
> some reasonably simple technique that would simulate it's functionality?
>
> [aTextField setValidCharacterSet: [NSCharacterSet
> decimalDigitCharacterSet]];
All you need is a custom NSFormatter subclass. Read the NSFormatter API,
particularly -isPartialStringValid:newEditingString:errorDescription:
Best,
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