右键单击NSStatusItem [英] Right-click on a NSStatusItem
问题描述
我有一个 NSStatusItem
,我想通过右键单击项目弹出菜单。我子类化一个NSView并覆盖了 - (void)rightMouseDown:(NSEvent *)event
方法。我还实现了 - (void)mouseDown:(NSEvent *)event
查看modifierflags。我的问题是,视图不接受 NSRightMouseDown
- 事件。我不知道为什么?任何想法如何得到这个事件?当然,我添加了自定义视图到statusitem。
- UPDATE -
其他信息:我已将NSImageView添加到自定义视图的子视图。
- UPDATE 2 -
其他信息:符合 NSMenuDelegate
协议。
确定。问题解决了。问题是 NSImageView
。我子类化它现在我重定向所有 mouseDown
和 rigthMouseDown
事件到其超级视图(我的自定义视图) >
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.
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).
这篇关于右键单击NSStatusItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!