如何在菜单项旁边添加一个复选符号,如此?
另外,如何修改与之关联的值?截至目前,我有以下代码:
//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];
答案 0 :(得分:4)
检查链接到menuItem的状态。
[statusItem setState:NSONState];
当项目处于开启状态时,应显示检查