在菜单项旁边添加复选标记

时间:2014-11-14 15:50:12

标签: objective-c menuitem

如何在菜单项旁边添加一个复选符号,如此? List of possible keyboard inputs

另外,如何修改与之关联的值?截至目前,我有以下代码:

//Create the menu

theMenu = [[NSMenu alloc] initWithTitle:@""];
[theMenu setAutoenablesItems:NO];

[theMenu addItemWithTitle:@"Enabled" action:@selector(logIt) keyEquivalent:@""];
[theMenu addItem:[NSMenuItem separatorItem]];

[theMenu addItemWithTitle:@"About" action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
[theMenu addItemWithTitle:@"Check For Updates" action:nil keyEquivalent:@""];

[theMenu addItem:[NSMenuItem separatorItem]];

[theMenu addItemWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@""];

NSStatusBar *statusBar = [NSStatusBar systemStatusBar];
statusItem = [statusBar statusItemWithLength:NSVariableStatusItemLength];
[statusItem setImage:[NSImage imageNamed:@"Icon2.png"]];
[statusItem setToolTip:_appName];
[statusItem setHighlightMode:YES];
[statusItem setMenu:theMenu];

1 个答案:

答案 0 :(得分:4)

检查链接到menuItem的状态。

[statusItem setState:NSONState];

当项目处于开启状态时,应显示检查