右键单击 NSStatusItem
我有一个 NSStatusItem,我想通过右键单击该项目来弹出一个菜单。我对 NSView 进行了子类化并覆盖了 - (void)rightMouseDown:(NSEvent *)event
方法。我还实现了 - (void)mouseDown:(NSEvent *)event
来查看修饰符标志。我的问题是,视图没有收到 NSRightMouseDown
-Event。而且我不知道为什么?有什么想法如何获得此活动吗?当然,我将自定义视图添加到了状态项中。
- 更新-
附加信息:我已将 NSImageView 添加到自定义视图的子视图中。
- 更新 2 -
附加信息:它符合 NSMenuDelegate
协议。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的。问题解决了。问题出在
NSImageView
上。我对它进行了子类化,现在我将所有mouseDown
和rigthMouseDown
事件重定向到其超级视图(我的自定义视图)。Ok. Problem solved. The problem was the
NSImageView
. I subclassed it and now I redirect allmouseDown
andrigthMouseDown
events to its superview (my custom view).