Fetch value from field editor during editing?
Fetch value from field editor during editing?
- Subject: Fetch value from field editor during editing?
- From: Russ <email@hidden>
- Date: Sun, 16 Nov 2008 17:18:23 -0800 (PST)
I need to be able to find the current value of a NSTextField even if it is being edited. I have the following code to check if it is being edited, and get the value from the field editor instead:
fresp = [[txtf window] firstResponder];
if ([fresp isKindOfClass:[NSTextView class]] && [(NSTextView*)fresp delegate] == txtf)
str = [(NSTextView*)fresp string]; // being edited, get from field editor
else
str = [txtf stringValue]; // not being edited, get from textfield itself
When the text field (txtf) is being edited, the first case is definitely used, but the wrong value still results. Ie suppose the original textfield contained 100, I click on it to edit it and change the value to 140. Now the code above runs (while the text field is still being edited). The result is the original 100, not the current 140, even though it is the field editor that is being queried.
How do I get the correct current value? This is a generic query, it can't end editing on the field or otherwise change the state. Needless to say, I'm more than a little surprised by this behavior. The whole field editor thing is kind of like hanging your underwear to dry in the living room to start with. Now the actual state seems to be even more opaque.
Thanks.
_______________________________________________
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