views:

29

answers:

1

How can I add a menu item inside a sub menu programmatically?

+1  A: 

Use -[NSMenu addItem:] et al, e.g.:

NSMenu *subMenu = ...;
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:@"foo" 
                    action:@selector(fooClicked:) keyEquivalent:@""]; 
[item autorelease];
[item setTarget:self];
[subMenu addItem:item];
Georg Fritzsche