问题
I have a NSStatusItem
and I want to popup a menu by rightclicking the item. I subclassed a NSView and overwrote the - (void)rightMouseDown:(NSEvent *)event
method. I also implemented - (void)mouseDown:(NSEvent *)event
for looking at the modifierflags. My problem is, that the view does not recieve the NSRightMouseDown
-Event. And I don't know why? Any ideas how to get this event? Naturally I added the custom view to the statusitem.
- UPDATE -
Additional information: I have added a NSImageView to my custom view's subviews.
- UPDATE 2 -
Additional information: It conforms to the NSMenuDelegate
protocol.
回答1:
Ok. Problem solved. The problem was the NSImageView
. I subclassed it and now I redirect all mouseDown
and rigthMouseDown
events to its superview (my custom view).
来源:https://stackoverflow.com/questions/2169454/right-click-on-a-nsstatusitem