• 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
NSNumberFormatter behavior with minimum/maximum values.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSNumberFormatter behavior with minimum/maximum values.


  • Subject: NSNumberFormatter behavior with minimum/maximum values.
  • From: Tom Coates <email@hidden>
  • Date: Thu, 9 Nov 2006 10:49:40 -0800

I'm having difficulty understanding how to use an NSNumberFormatter in an NSTextField to only allow numbers within a certain range to be entered. I have a sheet-panel with the NSTextField. The Text field has the formatter "embedded" in it. The Panel also has an OK button which allows accepting the value. I don't want to let the user enter numbers outside of a range, say from 0 to 10. I've entered that range into the formatter settings.

The behavior I get is that the NSTextField will let me input "illegal" values, but won't let me Tab out of the field unless I put in correct values. I get a Beep instead. I guess this means that formatter won't let the field resign its first responder status. But the OK Button still works and lets the user effectively enter the value. I'm not expecting that behavior by default. But I can't figure out how I'm supposed to disable the button based on the formatter's rejection of the bad value.

So far I haven't been able to find any documentation on how the Minimum and Maximum controls should be used in an effective UI.
• Is there a tutorial somewhere that better explains how to use NSFormatter to limit input?
• Is it possible to wire up the behavior I need using Interface Builder?
• How does one detect that the NSNumberFormatter would reject the value shown?
• Is this a bindings sort of problem? I would think I should be able to get the OK Button to disable itself when the formatter has an "invalid data" property.


This has to be a common problem. But maybe I'm expecting too much to be automatic. Any suggestions appreciated.

Tom :::/ _______________________________________________
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


  • Prev by Date: Re: Creating an NSTimer subclass
  • Next by Date: Custom app class and NSApplicationLoad
  • Previous by thread: Re: Pass paramters to application started from login items (in user prefs)
  • Next by thread: Re: NSNumberFormatter behavior with minimum/maximum values.
  • Index(es):
    • Date
    • Thread