I'm having an NSView
, which is set as the view:
outlet of an NSMenuItem
. The view contains an NSTableView
(inside an NSScrollView
) and an NSSearchField
. The NSMenu
is shown when the user clicks a specific NSStatusItem
. When I launch the application from Xcode (Build and Run), the controls behave well, but whenever I launch it from the Finder (like the users would), they don't work and don't take any focus. My application is an LSUIElement
. Can anyone help me out? Thanks.
views:
119answers:
1
+1
A:
Since, your application is an UIElement
, it's NSMenu
won't take focus. You must set an NSTimer
to 0.01 seconds to show the NSMenu
, and you should make the application active:
- (void)statusItemClicked {
[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(showMenu) userInfo:nil repeats:NO];
[NSApp activateIgnoringOtherApps:YES];
}
- (void)showMenu {
[statusItem popUpStatusItemMenu:statusMenu];
}
Time Machine
2010-03-20 17:37:36
Wow cool! Thanks, myself! That worked great!
Time Machine
2010-03-20 17:37:56