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 08:00:34 -0400
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.
@implementation NSMenu ( myAdditions )
-(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;
}
@end
On Apr 12, 2007, at 7:50 AM, Nicko van Someren wrote:
Cocoa People,
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]; }
Cheers,
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:
40verizon.net
This email sent to email@hidden
_______________________________________________
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