Any ideas on why the field editor doesn't report the value as it is being 
edited? 

A further problem I've encountered: controlTextDidChange is called very 
infrequently --- only after committing the edit, after changing focus. I'm 
looking for notifications after each character --- that's my definition of when 
the field changed --- it is showing a different value, so let know, so I can 
update the REST of the UI to reflect the new, if only partially changed, name. 
That real-time responsiveness is important. (Not to fear about undo, the undos 
coalesce.)

-----
Message: 15
Date: Sun, 16 Nov 2008 17:18:23 -0800 (PST)
Subject: Fetch value from field editor during editing?
To: cocoa-dev@lists.apple.com

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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to