I am programmatically creating an NSMenu
with a NSMenuItem
. When the window of the application is active, the NSMenuItem
is enabled:
However, as soon as the window loses focus the menu item becomes disabled:
Here's how I am creating the NSMenu
:
- (void)_quit
{
[[NSApplication sharedApplication] terminate:nil];
}
- (NSMenu *)_setupMenu
{
NSMenu *statusMenu = [[NSMenu alloc] initWithTitle:@"Demo"];
NSMenuItem *quit = [[NSMenuItem alloc] initWithTitle:@"Quit" action:@selector(_quit) keyEquivalent:@""];
[statusMenu addItem:quit];
return statusMenu;
}
What is causing this issue? And how do I go about making it enabled regardless of whether the application is in focus or not?