Re: Force an NSTextField to give up focus
Re: Force an NSTextField to give up focus
- Subject: Re: Force an NSTextField to give up focus
- From: Stéphane Sudre <email@hidden>
- Date: Sun, 13 Mar 2005 23:01:44 +0100
On dimanche, mars 13, 2005, at 10:57 PM, Gwynne wrote:
I have a window with two NSTextFields and an NSButton. There are no
bindings involved, and neither of the fields has a target or action.
When the button is activated, I need one of the fields to receive the
user focus. I tried [window makeFirstResponder:firstField], but it
only worked if the focus was either already on that field or on the
button. If the focus was on the second field, there was no effect. I
tried all sorts of calls, including -endEditingFor:,
-selectNextKeyView:, and all combinations of setting the first
responder to the window, nil, and the first field, but nothing worked.
Finally, in order to get the second field to give up focus, I had to
disable it, call makeFirstResponder for the first field, and re-enable
the second field during the next iteration of the run loop.
What am I doing wrong here? The second field has an NSFormatter
attached, but the problem continued even when I tried removing the
formatter. The Tab key works perfectly. These calls were being made
from the action method of the button.
Is the initialFirstResponder outlet set for the window?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden