简体   繁体   English

右键单击NSStatusItem

[英]Right-click on a NSStatusItem

I have a NSStatusItem and I want to popup a menu by rightclicking the item. 我有一个NSStatusItem ,我想通过右键单击该项来弹出菜单。 I subclassed a NSView and overwrote the - (void)rightMouseDown:(NSEvent *)event method. 我将NSView子类化并覆盖了- (void)rightMouseDown:(NSEvent *)event方法。 I also implemented - (void)mouseDown:(NSEvent *)event for looking at the modifierflags. 我还实现了- (void)mouseDown:(NSEvent *)event来查看modifierflags。 My problem is, that the view does not recieve the NSRightMouseDown -Event. 我的问题是,视图没有收到NSRightMouseDown And I don't know why? 我不知道为什么? Any ideas how to get this event? 如何获得此活动的任何想法? Naturally I added the custom view to the statusitem. 当然,我将自定义视图添加到statusitem。

- UPDATE - - 更新 -
Additional information: I have added a NSImageView to my custom view's subviews. 附加信息:我已将NSImageView添加到自定义视图的子视图中。

- UPDATE 2 - - 更新2 -
Additional information: It conforms to the NSMenuDelegate protocol. 附加信息:它符合NSMenuDelegate协议。

Ok. 好。 Problem solved. 问题解决了。 The problem was the NSImageView . 问题是NSImageView I subclassed it and now I redirect all mouseDown and rigthMouseDown events to its superview (my custom view). 我将其子类化,现在我将所有mouseDownrigthMouseDown事件重定向到其rigthMouseDown (我的自定义视图)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM