开发者

How to keep focus on NSStatusItem until toggling it again

I'm building an app the uses a NSStatusItem. I'm wanting my NSStatusItem to open when clicked and stay open until the user clicks the NSStatusItem again. As of right now, it opens the menu but the NSStatusItem loses focus when I click away from it or click on another app. I would for the NSStatusItem's menu to stay open until the user clicks to close it. Here's my code so far just to make the NSStatusItem. Thanks

-(void)awakeFromNib{
    statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLen开发者_C百科gth:NSVariableStatusItemLength] retain];
    [statusItem setMenu:statusMenu];
    [statusItem setTitle:@"Status"];
    [statusItem setHighlightMode:YES];
}


You would probably be best off implementing a custom window that opens when you click the status item rather than using a view attached to the status item's menu.

Menus have well-defined opening/closing/mouse tracking behaviour and trying to change it in a subclass will probably just be frustrating.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜