0

How may I get the NSMenu for the application menu (the one in the menu bar next to the apple menu).

This doesn't work on my old carbon app, mainMenu returns nil.

NSMenu *mainMenu = [[NSApplication sharedApplication] mainMenu];
NSMenu *appMenu = [[mainMenu itemAtIndex:0] submenu];

for (NSMenuItem *item in [appMenu itemArray]) {
    NSLog(@"%@", [item title]);
}
subzero
  • 3,420
  • 5
  • 31
  • 40

1 Answers1

0

I don't know how (or if it's possible) to get an NSMenu ref for a Carbon menu, but I found this in some old code of mine:

GetIndMenuItemWithCommandID( 0, kHICommandQuit, 1, &applicationMenu, NULL );
bern
  • 11
  • 2