Adding menus to main menu
Adding menus to main menu
- Subject: Adding menus to main menu
- From: Bruce Truax <email@hidden>
- Date: Fri, 16 Sep 2005 10:07:27 -0400
When a particular editing window opens in my application I would like to add
a new menu to the main menu bar. The items contained in this menu will be
the same items which are in a contextual menu that is used within the
editor. I would like to know how to programmatically add a menu to the main
menu. I can get the main menu object as follows:
NSApplication *thisApp = [NSApplication sharedApplication];
//Now get the main menu object
NSMenu *theMainMenu = [thisApp mainMenu];
My problem is that the documentation for NSMenu tells how to add an
NSMenuItem using the addItem and insertItem methods. My understanding is
that these will let you add another item (NSMenuItem) to an existing drop
down menu but they will not let you add a new drop down menu which is an
NSMenu.
Another option would be to use the validateMenuItem method but that only
allows menu items to be greyed out and I would like the entire menu not only
be disabled but to be removed or made invisible.
Part of my problem is that I am also somewhat confused as to the structure
of the main menu bar. From my MainMenu.nib I see that the entire menu bar
is an NSMenu and so are each of the drop down menus in the main menu bar. I
assume that the entire menu bar can be build programmatically but I have not
been able to find how this is done anywhere in the Apple documentation.
Thanks.
Bruce
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden