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: Gwynne <email@hidden>
- Date: Sun, 13 Mar 2005 17:11:45 -0500
On Mar 13, 2005, at 5:01 PM, Stéphane Sudre 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?
Yes.
-- Gwynne, key to the Code
Email: email@hidden
Website: http://musicimage.plasticchicken.com/
"This whole world is an asylum for the incurable."
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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