On Apr 22, 2009, at 6:24 PM, Ulai Beekam wrote:


So I really must make a custom field editor to accomplish on-the-fly validation (i.e. disallowing on-the-fly invalid characters)?

I suppose I could do a custom field editor and override keyDown:, checking for characters in [NSCharacterSet decimalDigitCharacterSet], etc. In fact, having made some custom field editors in the past I know I would be able to do this. However, I consider this to be a somewhat lame hack :( I therefore want to make sure with you guys that there is no easier solution to this, e.g. to somehow use the number formatter as a basis for automatic on-the-fly validation.

The whole thing just seems strange to me. Because when the text field is not bound, on-the-fly validation seems to work just fine! But this great feature goes away as soon as the text field is bound. That is, as soon as the text field is bound, the validation stops being on-the-fly and goes elsewhere instead. Is there no way having the validation ALSO as an on-the-fly thing? Hmmmm.control:didFailToFormatString:errorDescription:

Using control:didFailToFormatString:errorDescription: and always returning YES will stop the "Formatting Error" sheet.

A custom NSNumberFormatter subclass can be used to block characters that are not in decimalDigitCharacterSet and sound a beep. Read the last paragraph of: <http://developer.apple.com/documentation/Cocoa/Conceptual/DataFormatting/Articles/CreatingACustomFormatter.html >

--Nathan


_______________________________________________

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