I have a cocoa application running on Mac OS 10.6.8 I am adding an entry to apple menu in the app, for quitting my application. The code is like this:
item = [menu addItemWithTitle: @"Quit Myapp" , NSLocalizedString(@"Quit", nil), applicationName] action:@selector(terminate:) keyEquivalent:@"q"];
[item setTarget:NSAPP];
Now, my problem is that when a modal dialog is opened using runModal
of NSOpenPanel
, this quit menu item is still enabled. Rest of the menu items are disabled as usual. I am not able to understand why.
If I change the above code so that menu item's target is not NSApp, but another cocoa object, then the problem disappears.
Could someone please let me know if it is a known issue. Is it wrong to set the NSApp as a menu item's target?