Revision: 3817
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 18, 2007 09:26 by 0xced
Initial Code
// Beware: the keyEquivalent must be lowercase in order not to have the shift modifier NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:@"Action" action:@selector(menuItemAction:) keyEquivalent:@"r"]; [menuItem setTarget:self]; [menuItem setKeyEquivalentModifierMask:NSCommandKeyMask | NSAlternateKeyMask]; // Add the menu item at the end of menu whose index is 1 (most probably the File menu) [[[[NSApp mainMenu] itemAtIndex:1] submenu] addItem:menuItem];
Initial URL
Initial Description
Programmatically add a menu item
Initial Title
Add a menu item
Initial Tags
Initial Language
Objective C