3
我正在構建一個應用程序,使用NSStatusItem。我希望我的NSStatusItem在單擊時打開並保持打開狀態,直到用戶再次單擊NSStatusItem。截至目前,它會打開菜單,但當我點擊它或點擊其他應用程序時,NSStatusItem會失去焦點。我會爲NSStatusItem的菜單保持打開狀態,直到用戶單擊關閉它。這是我的代碼,目前只是爲了製作NSStatusItem。由於如何繼續關注NSStatusItem,直到再次切換爲止
-(void)awakeFromNib{
statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength] retain];
[statusItem setMenu:statusMenu];
[statusItem setTitle:@"Status"];
[statusItem setHighlightMode:YES];
}