• 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
Re: Retriving the tag of superMenu Items
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Retriving the tag of superMenu Items


  • Subject: Re: Retriving the tag of superMenu Items
  • From: "Louis C. Sacha" <email@hidden>
  • Date: Mon, 6 Dec 2004 17:39:43 -0800

Hello...

Menus don't have tags, but the menu item the menu is attached to can have one.

To get the tag of the menu item that anchors the submenu, you would do something like this:

	id <NSMenuItem> selectedMenuItem;  /* given a particular menu item */

NSMenu *parentMenu = [selectedMenuItem menu];
NSMenu *grandparentMenu = [parentMenu supermenu];
id <NSMenuItem> parentMenuItem = [grandparentMenu itemAtIndex:[grandparentMenu indexOfItemWithSubmenu:parentMenu]];


	int parentTag = [parentMenuItem tag];

Hope that helps,

	Louis


Hi,
I have a menu item called Fruits" with some sub menus.

Fruits
    Winter
        Orange
        Tangerine
    Summer
        Strawberry
        Melon

If the user choses the item "Melon", how can I get the tag of its superMenus
(items) Summer and Fruits?
I have already

- (IBAction)ChoiseFromMenuFruits:(id)sender
{
int tag = [sender tag]; // this is the tag of the item Melon
// if I ask [[sender menu] tag]
// Xcode tells me there is not tag in a menu
}




Best Regards
--
Lorenzo
email: email@hidden

_______________________________________________
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


References: 
 >Retriving the tag of superMenu Items (From: Lorenzo <email@hidden>)

  • Prev by Date: Release understanding help…
  • Next by Date: NSView not resizing when parent view resizes
  • Previous by thread: Retriving the tag of superMenu Items
  • Next by thread: Re: How to create a button dynamically and set action in subclass
  • Index(es):
    • Date
    • Thread