• 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: Matt Neuburg <email@hidden>
  • Date: Wed, 02 Jul 2008 07:04:35 -0700
  • Thread-topic: setFirstResponder to NSTextField fails 1st time, works next

On Wed, 2 Jul 2008 00:20:53 -0400, Moses Hall <email@hidden> said:
>Hi folks,
>
>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.
>
>This is happening inside an NSPanel subclass...
>
>@implementation IPAPanel
>-(BOOL)canBecomeKeyWindow {return YES;}
>-(BOOL)canBecomeMainWindow {return NO;}
>-(void)awakeFromNib
>{
>   [self setHidesOnDeactivate:NO];
>   [self setBecomesKeyOnlyIfNeeded:YES];
>}
>@end
>
>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"])

What's the purpose of this test? Is it necessary? Is it working? Try putting
an NSLog inside the test to see whether it is passing/failing when you think
it should be.

>   {
>     [_window makeKeyWindow];
>     [_window makeFirstResponder:_searchText];
>   }
>   NSLog(@"first responder: %@", [_window firstResponder]);
>}

m.

--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



_______________________________________________

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

  • Follow-Ups:
    • Re: setFirstResponder to NSTextField fails 1st time, works next
      • From: Moses Hall <email@hidden>
    • Re: setFirstResponder to NSTextField fails 1st time, works next
      • From: Moses Hall <email@hidden>
  • Prev by Date: Re: KVC/KVO compliance of a container adding multiple objects [SOLVED]
  • Next by Date: Re: Bindings - registering change notification for multiple keys
  • Previous by thread: setFirstResponder to NSTextField fails 1st time, works next
  • Next by thread: Re: setFirstResponder to NSTextField fails 1st time, works next
  • Index(es):
    • Date
    • Thread