• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Bindings making NSNumberFormatter strange
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bindings making NSNumberFormatter strange


  • Subject: Re: Bindings making NSNumberFormatter strange
  • From: Nathan Kinsinger <email@hidden>
  • Date: Wed, 22 Apr 2009 19:00:13 -0600

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 (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


  • Follow-Ups:
    • RE: Bindings making NSNumberFormatter strange
      • From: Ulai Beekam <email@hidden>
References: 
 >Bindings making NSNumberFormatter strange (From: Ulai Beekam <email@hidden>)
 >RE: Bindings making NSNumberFormatter strange (From: Ulai Beekam <email@hidden>)
 >Re: Bindings making NSNumberFormatter strange (From: Keary Suska <email@hidden>)
 >RE: Bindings making NSNumberFormatter strange (From: Ulai Beekam <email@hidden>)

  • Prev by Date: Forcing controller to update binding of compound value
  • Next by Date: Re: Quick question about adding an NSPanel
  • Previous by thread: RE: Bindings making NSNumberFormatter strange
  • Next by thread: RE: Bindings making NSNumberFormatter strange
  • Index(es):
    • Date
    • Thread