• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Removing submenus from a menu
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Removing submenus from a menu
      • From: j o a r <email@hidden>
  • Prev by Date: Re: Aqua Human Interface and Safari
  • Next by Date: Re: Removing submenus from a menu
  • Previous by thread: Re: count only defined for abstract class
  • Next by thread: Re: Removing submenus from a menu
  • Index(es):
    • Date
    • Thread