• 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 Changes Reflected In NSTextField
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSNumberFormatter Changes Reflected In NSTextField


  • Subject: NSNumberFormatter Changes Reflected In NSTextField
  • From: Simon Wolf <email@hidden>
  • Date: Fri, 9 May 2008 16:59:17 +0100

I have an NSTextField with an associated NSNumberFormatter which I am using to format the values shown to a specific number of decimal places. I have a second NSTextField which I am using to display and edit the number of decimal places that I want shown and I have used the controlTextDidEndEditing delegate method to detect a change. Upon a change I am using the setMinimumFractionDigits and setMaximumFractionDigits methods of the NSNumberFormatter to change the number of decimal places to be shown but I am having trouble getting the NSTextField to refresh without giving the control the focus.

If I change the value of the field then the value is displayed correctly:

float temp;
temp = [netAmountField floatValue];
temp++;
[netAmountField setIntValue:(int)temp];

If I don't actually change the value then the NSTextField is not refreshed:

[netAmountField setFloatValue:[netAmountField floatValue]];

I'm fairly sure that this is simply due to the NSTextField being clever enough to realise that the value has not changed and therefore it doesn't re-display the value and trigger the new format and I am equally sure that I'm missing a simple way to achieve the refresh but after an hour of messing around I though I'd ask wiser folk.

Many thanks.

Simon
_______________________________________________

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: NSNumberFormatter Changes Reflected In NSTextField
      • From: Simon Wolf <email@hidden>
  • Prev by Date: Re: Threading - How its done?
  • Next by Date: holding NSOutlineView from display
  • Previous by thread: Re: NSApplicationMain & Main NIB File
  • Next by thread: Re: NSNumberFormatter Changes Reflected In NSTextField
  • Index(es):
    • Date
    • Thread