1

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?

Community
  • 1
  • 1
Lee
  • 11
  • 2
  • last remark of this post might help you. http://www.cocoabuilder.com/archive/cocoa/195835-set-focus-on-nsview-in-an-nsmenuitem.html – bluedome Jan 28 '15 at 05:20
  • 1
    could you post your solution to help someone who has same problem? you could answer your own question. – bluedome Jan 30 '15 at 00:09

0 Answers0