• 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: Andy Lee <email@hidden>
  • Date: Thu, 12 Apr 2007 13:32:29 -0400

On Apr 12, 2007, at 7:50 AM, Nicko van Someren wrote:
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]; }

Offhand I don't see a built-in way to do it. I'd file an enhancement request, since this seems like something people could need from time to time.


My first thought was poseAs. You could override NSView's - menuForEvent: so that it remembers self in a global variable, so you can always see what the last view was that did a -menuForEvent:. Your menu action could assume that was the view that was right- clicked. Then you could have your subclass pose as NSView. But IIRC, poseAs is going away in Leopard. Maybe instead of poseAs, you could try a method-swapping hack as described here: http:// theocacao.com/document.page/266.

Does somebody have a less hacky way?

--Andy


_______________________________________________

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


  • Follow-Ups:
    • Re: Getting the context of a context menu
      • From: Nicko van Someren <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>)

  • Prev by Date: Re: WM_KEYDOWN
  • Next by Date: Re: Can a value transformer get its own registration name?
  • 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