• 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: NSTextField getting input number by number
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextField getting input number by number


  • Subject: Re: NSTextField getting input number by number
  • From: "Louis C. Sacha" <email@hidden>
  • Date: Sun, 16 Nov 2003 17:27:41 -0800

Hello...

I think what was happening was that the NSTextView was trying to update itself when you made the

float1 = [textField1 floatValue];

call. It would internally end the editing, convert the string to a float to validate the input, reset itself to a string made from the float, and then return the float to you. So, it was causing the unintentional update of the value internally from "1." back to "1", loosing the decimal point.

What the other version

float1 = [[[[aNotification userInfo] objectForKey:@"NSFieldEditor"] string] floatValue];

does is get the string from the NSFieldEditor which is the shared NSText object that belongs to the window and is used as sort of as a text input buffer when you edit any type of text field. Since you're getting the string from that buffer (and then converting it a float), the NSTextField doesn't even need to know that you are reading the string, and it doesn't try to update itself. That's probably the reason why the @"NSFieldEditor" key/object is sent in the notification's userInfo dictionary, to avoid an unintentional update of the NSControl (the NSTextField) by allowing you to read from the buffer directly.

Louis

Althoug I am not sure exactly why this works, the suggestion that you noted
below does work:

float1 = [[[[aNotification userInfo] objectForKey:@"NSFieldEditor"] string]
floatValue];

Thank you to everyone for all of your help and especially louis. You are a
testimate to the helpful nature of the apple community and a great help on
this mailing list.

I will keep everyone updated.

Thanks again,
-jay
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: NSTextField getting input number by number (From: "Jay Rimalrick" <email@hidden>)

  • Prev by Date: Re: Address Book manipulations - best approach
  • Next by Date: Re: Another Linker Problem: version mismatch for library
  • Previous by thread: Re: NSTextField getting input number by number
  • Next by thread: Foundation with autoconf, automake, and libtool
  • Index(es):
    • Date
    • Thread