• 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: Building a calculator text field: problem with NSFormatter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Building a calculator text field: problem with NSFormatter


  • Subject: Re: Building a calculator text field: problem with NSFormatter
  • From: Keary Suska <email@hidden>
  • Date: Thu, 30 Nov 2006 11:37:12 -0700
  • Thread-topic: Building a calculator text field: problem with NSFormatter

on 11/29/06 10:50 PM, email@hidden purportedly said:

> So, any ideas how to make the text field wait until the user is finished
> to submit its value to the NSFormatter?  Or, perhaps there is another
> approach that would work better --- subclassing NSTextField, a
> delegate?  Perhaps there is already a "NSCalculatingTextField" and I
> just missed it?

How Cocoa handles formatters is (IMHO) odd and counter intuitive.
getObjectValue:forString:errorDescription: is called for every key press,
although any errors returned are ignored until the field loses focus. This
may or may not be effected by a binding "validates immediately"--haven't
tested to be sure.

The most direct way to do what you want would be to use a validator instead
of a formatter, but you *could* use a formatter if you have some trigger
value, say, an equals character. If you evaluate the "expression" only when
the string value ends in an equals, you will probably get what you want.

Best,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: Building a calculator text field: problem with NSFormatter
      • From: Niko Matsakis <email@hidden>
References: 
 >Building a calculator text field: problem with NSFormatter (From: Niko Matsakis <email@hidden>)

  • Prev by Date: Re: Problems with NSArrayController and keyPath Operator
  • Next by Date: Getting the text out of iWork Pages file
  • Previous by thread: Building a calculator text field: problem with NSFormatter
  • Next by thread: Re: Building a calculator text field: problem with NSFormatter
  • Index(es):
    • Date
    • Thread