• 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
Fetch value from field editor during editing?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Prev by Date: Re: newbie NSMutable dictionary subclass question
  • Next by Date: Two arrays sharing the same adress space.
  • Previous by thread: Re: newbie NSMutable dictionary subclass question
  • Next by thread: Re: Fetch value from field editor during editing?
  • Index(es):
    • Date
    • Thread