Re: Finding which control is selected
Re: Finding which control is selected
- Subject: Re: Finding which control is selected
- From: Peter Sichel <email@hidden>
- Date: Thu, 18 Oct 2001 16:32:34 -0400
Thanks of your response. Here's what I'm trying to do.
I have a window with two NSTextFields. When the user clicks
on a button in the window, I want to determine which of the
two NSTextFields has input focus.
[window firstResponder] is equal to the window itself, so doesn't help.
[window fieldEditor: forObject:] returns the field editor, but
this doesn't appear to tell me which control has input focus.
What am I missing?
- Peter
The first responder _is_ the control (or more generally, the NSView)
with the input focus. If you want to see if the first responder is
equal to a certain control (i.e. one of your outlets), just use ==.
The only place where this doesn't work is with NSTextField. When an
NSTextField is selected, the window's field editor becomes the first
responder, not the text field itself.
--