Re: setFirstResponder to NSTextField fails 1st time, works next
Re: setFirstResponder to NSTextField fails 1st time, works next
- Subject: Re: setFirstResponder to NSTextField fails 1st time, works next
- From: Moses Hall <email@hidden>
- Date: Mon, 21 Jul 2008 20:14:37 -0400
SOLVED: I'm posting this for the sake of the archives, in case anyone
else has this problem.
I found that making the window the first responder before making the
text field first responder solves the problem. Apparently the window
is *not* first responder the first time the user selects the search
tab, but it *is* subsequently. This change causes the makeKeyWindow
call to succeed in all cases.
-(void)tabView:(NSTabView*)tv didSelectTabViewItem:(NSTabViewItem*)item
{
if ([[item identifier] isEqual:@"Search"])
{
[_window makeFirstResponder:_window];
[_window makeKeyWindow];
[_window makeFirstResponder:_searchText];
}
}
Cheers,
-- Moses
Here's a problem I'm having under Tiger, developing an LSUIElement
application (Input Method server -- it's the UI for IPA Palette
[www.blugs.com/IPA]). I have an NSTabView, one of whose panes has a
search field which is an NSTextField subclass (note that the same
problem occurs if I use an NSTextField). I want to make this field
the first responder when the "Search" tab is chosen. Oddly, it does
not become first responder the first time the pane is selected. It
does not become key, and does not accept text (unless clicked on). If
I move to a different tab and come back, then I get the desired
result: the focus ring is there and I can type into the field.
<snip>
Here is my tab switch delegate method:
-(void)tabView:(NSTabView*)tv didSelectTabViewItem:(NSTabViewItem*)
item
{
NSLog(@"first responder WAS %@", [_window firstResponder]);
if ([[item identifier] isEqual:@"Search"])
{
[_window makeKeyWindow];
[_window makeFirstResponder:_searchText];
}
_______________________________________________
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