ruben1691
ruben1691

Reputation: 423

Add checkmark next to menu item

How can I add a check symbol next to a menu item, like so? List of possible keyboard inputs

Also, how do I modify the value associated with it? As of now, I have the following code:

//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];

Upvotes: 2

Views: 2639

Answers (1)

NQuinn27
NQuinn27

Reputation: 116

The check is linked to the state of the menuItem.

[statusItem setState:NSONState];

The check should appear when the item is in ON State

Upvotes: 6

Related Questions