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: 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