• 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: number formatters and bindings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: number formatters and bindings


  • Subject: Re: number formatters and bindings
  • From: "Clint Shryock" <email@hidden>
  • Date: Thu, 4 Jan 2007 07:10:59 -0600

i've done something similar just by subclassing NSFormatter and overridding
the method
- (BOOL)isPartialStringValid:(NSString<http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/doc/c_ref/NSString>**)
*partialStringPtr*
proposedSelectedRange:(NSRangePointer<http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSRangePointer>
)*proposedSelRangePtr* ...

and attaching it to the text box in awakeFromNib:
if the user types in something that is not valid nothing happens, but if
they type something that is valid it suggests the rest of the word (kind of
like code complete or something).

see here:
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSFormatter_Class/index.html

+Clint

On 1/3/07, I. Savant <email@hidden> wrote:


   I haven't checked the archives myself, but what about doing this
during validation ( -validate<Key>:error: )? Do any necessary
corrections there, but always return YES and no error should be
displayed.

   Disclaimer: I haven't tried this, just an idea.

--
I.S.


On Jan 3, 2007, at 11:51 PM, Sean McBride wrote:

> Mitchell Livingston (email@hidden) on 2006-12-30 12:47 said:
>
>> I want to have a text field where a user can only enter in numbers
>> within a certain range (usually 0 and up) but it also needs to use
>> bindings. When I use bindings and number formatters and enter an
>> invalid value I get a error dialog with "Invalid number" or "Fell
>> short of minimum" and the options  "OK" and "Discard Changes". Is
>> there a way to make the field simply beep and revert to the previous
>> values (or something similar)?
>
> I seem to remember other questions in the past about changing that
> dialog (I think I asked too).  Did you check the archives?  IIRC,
> there
> is nothing to be done.  :(  Except visiting radar of course.
>
> Sean
>
> --
> "Whoever controls the past, controls the future" - George Orwell
>
>
> _______________________________________________
>
> 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:
> 40gmail.com
>
> This email sent to email@hidden

_______________________________________________

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

_______________________________________________

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


References: 
 >number formatters and bindings (From: Mitchell Livingston <email@hidden>)
 >Re: number formatters and bindings (From: "Sean McBride" <email@hidden>)
 >Re: number formatters and bindings (From: "I. Savant" <email@hidden>)

  • Prev by Date: Re: using long double math functions like sinl() with Cocoa
  • Next by Date: Re: Confusing terms - menu/menubar
  • Previous by thread: Re: number formatters and bindings
  • Next by thread: Re: number formatters and bindings
  • Index(es):
    • Date
    • Thread