Removing submenus from a menu
Removing submenus from a menu
- Subject: Removing submenus from a menu
- From: Greg Hurrell <email@hidden>
- Date: Mon, 13 Jan 2003 02:29:21 +1030
I'm grappling with NSMenus for the first time and I know how to add and
remove basic items fairly easily. I also know how to add submenus
(create the NSMenuItem that will contain the submenu, make the NSMenu
that will be the submenu itself, set the submenu to be a submenu of the
item, then insert your item into the menu).
But how do I remove them? Everything I try ends up crashing the app.
I've tried the following, among other things:
// using an integer index for the NSMenuItem that I wish to remove
[theMenu removeItemAtIndex:theIndex];
and:
// using an id pointer to the NSMenuItem object I wish to remove
[theMenu removeItem:objectToRemove];
and
// using an id pointer to the NSMenuItem object I wish to remove
[theMenu setSubmenu:nil forItem:objectToRemove];
None work without crashing the app. What method should I be using?
Can't seem to find any answers in my trusty Cocoa book by Anguish et
al, nor on the web...
I was hoping this would be easy. I have a user pref to toggle that
submenu on and off, and I would like to be able to quickly and easily
either hide it completely or show it. In theory I should be able to
hide/show/hide/show to my heart's content, but at the moment I can't
even manage the "hide" part!
Cheers :-)
Greg
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.