• 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: Getting the context of a context menu
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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 20:33:48 -0400

Contextual menu needs to know which view it was connected to:
Cause the delegate of the menu to be the view for which it was attached.
When pulled down it should execute -menuNeedsUpdate: in the delegate (the view).
From this action, anything can be done (including changing the menu).
Inclusive will be the requirement of item enabling and menuHasKeyEquivalent:forEvent:target:action: defined in the delegate.


On Apr 12, 2007, at 5:55 PM, Andy Lee wrote:

Carmin, did you read Nicko's clarification? He's not trying to get the supermenu. There *is* no supermenu. He's talking about a contextual menu. Do you know about contextual menus that can be attached to NSViews? The user can right-click on the view and the menu appears. That is a contextual menu.

Nicko has multiple NSViews sharing a common NSMenu instance as their contextual menu. When a contextual menu is selected from he wants the resulting action method to know which NSView was right- clicked.

Are you saying your code returns an NSView?

--Andy

On Apr 12, 2007, at 5:24 PM, Carmin Politano wrote:

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

_______________________________________________

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


References: 
 >Getting the context of a context menu (From: Nicko van Someren <email@hidden>)
 >Re: Getting the context of a context menu (From: Carmin Politano <email@hidden>)
 >Re: Getting the context of a context menu (From: Nicko van Someren <email@hidden>)
 >Re: Getting the context of a context menu (From: Carmin Politano <email@hidden>)
 >Re: Getting the context of a context menu (From: Andy Lee <email@hidden>)

  • Prev by Date: My Slider has spikes
  • Next by Date: Re: My Slider has spikes
  • Previous by thread: Re: Getting the context of a context menu
  • Next by thread: Re: Getting the context of a context menu
  • Index(es):
    • Date
    • Thread