• 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
Getting NSSearchField to get focus in NSStatusItem menu
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting NSSearchField to get focus in NSStatusItem menu


  • Subject: Getting NSSearchField to get focus in NSStatusItem menu
  • From: Dalmazio Brisinda <email@hidden>
  • Date: Sat, 17 Oct 2009 02:53:32 -0600

Hi,

I'm having difficulty getting a NSSearchField to work properly in an NSStatusItem. What I would like to do is something similar to the spotlight status bar item and the search field that pops up.

After I create my view containing the NSSearchField and a also a simple menu in Interface Builder, I programmatically create my NSStatusItem, add a menu item for the NSSearchField to the previously created IB menu, add it to the menu item's view, and set the IB menu to become visible when the user clicks the status item.

- (void) awakeFromNib;
{
NSStatusBar * bar = [NSStatusBar systemStatusBar];
statusItem = [bar statusItemWithLength:NSSquareStatusItemLength];

NSString * imageName = [[NSBundle mainBundle] pathForResource:kBBStatusBarImage ofType:@"png"];
NSImage * statusBarImage = [[NSImage alloc] initWithContentsOfFile:imageName];
[statusItem setImage:statusBarImage];

imageName = [[NSBundle mainBundle] pathForResource:kBBStatusBarAltImage ofType:@"png"];
statusBarImage = [[NSImage alloc] initWithContentsOfFile:imageName];

[statusItem setAlternateImage:statusBarImage];
[statusItem setHighlightMode:YES];
[statusItem setEnabled:YES];

searchMenuItem = [[NSMenuItem alloc] initWithTitle:@""
action:@selector(performSearch:) keyEquivalent:@""];
[searchMenuItem setView:searchView];
[searchMenuItem setTarget:self];

[statusItemMenu insertItem:searchMenuItem atIndex:0];


	[statusItem setMenu:statusItemMenu];
}

Since I want the app to run without a menu bar and without a doc icon, I set the Info.plist property LSUIElement to YES. When I run the program, clicking on the status item causes the menu containing the NSSearchField to display as expected, but I can't select it or enter any data in the search field. Clicking around in the search field gives me these errors in the Console:

	HIViewSetFocus() failed with error -30599

And this ominous looking piece of Console:

09-10-17 1:28:55 AM BuskBar[11794] HIToolbox: ignoring exception '_NSDisplayOperationStack window mismatch on pop' that raised inside Carbon event dispatch
(
[...]
)


It seems the problem has something to do with the NSSearchField not being able to get focus because the NSStatusBarWindow (private class?) it seems to be associated with can't become key. Has anyone experienced this or know how to get this to work?

Best,
Dalmazio
_______________________________________________

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


  • Prev by Date: Re: Programming Style: Method Definition with or without a semicolon.
  • Next by Date: Re: Triggering a Method when a Core Data Property changes.
  • Previous by thread: Re: How to retrieve the font information from TrueType font file?
  • Next by thread: Re: Triggering a Method when a Core Data Property changes.
  • Index(es):
    • Date
    • Thread