• 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
Re: setFirstResponder to NSTextField fails 1st time, works next
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Re: setFirstResponder to NSTextField fails 1st time, works next (From: Matt Neuburg <email@hidden>)

  • Prev by Date: NSTextView overdraw bug in Leopard?
  • Next by Date: Re: how to prevent baseline shift when using NSSuperscriptAttributeName on a NSTextView's NSAttributedString ?
  • Previous by thread: Re: setFirstResponder to NSTextField fails 1st time, works next
  • Next by thread: Disabling column selection NSTableView
  • Index(es):
    • Date
    • Thread