右键单击 NSStatusItem

发布于 2024-08-19 09:00:38 字数 428 浏览 4 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

顾铮苏瑾 2024-08-26 09:00:38

好的。问题解决了。问题出在 NSImageView 上。我对它进行了子类化,现在我将所有 mouseDownrigthMouseDown 事件重定向到其超级视图(我的自定义视图)。

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文