My application resides in the status bar. When the application first starts my search field responds fine, and allows me to click and enter text and look like this.
But after clicking out of the application into another application like "xcode" and back into my menu the search field and the rest of the custom view appears dim and does not respond unless I click multiple times.
In my applicationDidFinishLaunching
I set up the statusItem
and the NSMenuItem
with the custom view.
//set up hotkeys
[self registerHotKeys];
_statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
NSImage *menuIcon = [NSImage imageNamed:@"Menu Icon"];
NSImage *highlightIcon = [NSImage imageNamed:@"Menu Icon"];
[highlightIcon setTemplate:YES];
[[self statusItem] setImage:menuIcon];
[[self statusItem] setAlternateImage:highlightIcon];
[[self statusItem] setMenu:[self menu]];
[[self statusItem] setHighlightMode:YES];
// search menu item
NSMenuItem *searchMenuItem = [[NSMenuItem alloc] initWithTitle:@"search" action:nil keyEquivalent:@""];
self.searchMenuItemView = [[SearchMenuItemView alloc] initWithNibName:@"SearchMenuItemView" bundle:nil];
self.searchMenuItemView.delegate = self;
[searchMenuItem setView:self.searchMenuItemView.view];
[searchMenuItem setTarget:self];
[searchMenuItem setEnabled:YES];
[_menu insertItem:searchMenuItem atIndex:0];
The view is coming from an UIViewController
, but I have tried setting the view from just an NSView
with no luck using "this" from someone with a similar issue but this did not solve mine. Auto enable is on.
Is there a way to bring the NSMenuItem
back to the state it was in when the application is first lunched?