• 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: Keary Suska <email@hidden>
  • Date: Wed, 22 Apr 2009 16:46:12 -0600

On Apr 22, 2009, at 3:57 PM, Ulai Beekam wrote:

To elaborate, when not using bindings, the default behavior of text fields with a number formatter is that when a user tries to enter "abc" in it, the text field refuses to lose focus and makes a beeping sounds.

However, when the text field's value binding has been set, a sheet is shown, which I think is a bad user experience.

That's because no one is handling the error. Bindings gives you some automatic error support. Otherwise you have to handle the error yourself. This is well documented. If you don't like the experience, then change it.


In fact it would be even better to just disallow entering of invalid characters in the first place. But such a method would have to work even if the text field's value binding is set.

I agree with you that having some sort of built-in support for entry filters would be great (I would add length limiters as well). I think we had this back in the Mac toolbox days, if I am remembering properly.


Anyway, there are two different issue to consider. One is validation, and the other is custom editor behavior. They are really two different problems, although there is overlap.

My problem is that when I type some invalid stuff in the text field, such as some letters "abc", I don't get a beep (which is the normal behaviour and the one I want), but I get some sheet popping up saying "Formatting Error". I don't want this sheet. I want the beep like usual. How can I get rid of this sheet behaviour that the bindings is causing? And why is it even causing it?


Because that's how formatters work. Getting rid of the sheet is nontrivial if you allow the formatter or bindings to do validation. Also, your formatter (or your model object, using key-value validation) can provide a more sensible error message if you choose.


Second question: How can I make my text field just disallow entering of invalid characters in the first place (and producing beep when it is tried)? I want, as you probably guessed, a method that is compatible with bindings.


You can use the formatter to check data on the fly, but you have to control the undo manager or you will get exceptions on undo. You can also have a custom field editor, for finer grained control. Both of these have decent documentation. I would be surprised if no-one has a framework that offers some of this behavior.

HTH,

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


  • 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>)

  • Prev by Date: Re: -[NSSharedWorkspace openFile:]: Application exits with status 255
  • Next by Date: [OT] Re: How to make app login window to look like OS X user login window ?
  • Previous by thread: RE: Bindings making NSNumberFormatter strange
  • Next by thread: RE: Bindings making NSNumberFormatter strange
  • Index(es):
    • Date
    • Thread