Re: Getting the context of a context menu
Re: Getting the context of a context menu
- Subject: Re: Getting the context of a context menu
- From: Carmin Politano <email@hidden>
- Date: Thu, 12 Apr 2007 17:24:17 -0400
Let me try this again... This is the code:
-(id) supermenuItem; {
// determine the item from the supermenu which uses this menu as the
submenu
NSMenuItem * zItem; NSEnumerator * eItems = [[[self supermenu]
itemArray] objectEnumerator];
while ( zItem = [eItems nextObject] )
if ( [zItem submenu] == self ) return zItem;
return nil;
}
On Apr 12, 2007, at 9:15 AM, Nicko van Someren wrote:
On 12 Apr 2007, at 13:00, Carmin Politano wrote:
On Apr 12, 2007, at 7:50 AM, Nicko van Someren wrote:
I have an application in which there is a number of UI objects
which require the same context menu. These items get a 'default
case' context menu which just allows the user to get actions like
extended help for the object under the menu. Many of these
objects are just NSButtons and the like, without any class
customisation. I have the common context menu in my .nib file
and I can connect it to the 'menu' outlet of each UI item without
any problem. The problem that then arises is that when a menu
action is triggered I can't seem to find out the context of the
context menu. The action sender is the menu item, and I can find
it's parent NSMenu, but not from where that menu was raised.
So, is there some way that I've not found to determine which
view was responsible for raising a context menu, or am I going to
have to subclass every standard UI item I use just so that I can
bolt in a -menuForEvent: method that says { menuContext = self;
return [self menu]; }
A menu can only belong to one supermenu.
If you want a menu to belong to more than one supermenu then you
will have to copy it.
I'm not attaching the menu as a sub-menu of some other menu, I am
attaching it as the context menu to each of a set of views. In
this mode the menu's supermenu is always nil.
Nicko
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden