Java 鼠标右键单击事件

发布于 2024-10-09 05:31:18 字数 130 浏览 0 评论 0原文

在我的三键鼠标上 MouseEvent.BUTTON2= 中键单击和 MouseEvent.BUTTON3 = 右键单击​​。

两键鼠标上是否存在这种情况?

谢谢

On my three button mouse MouseEvent.BUTTON2= Middle Click and MouseEvent.BUTTON3 = Right Click.

Is this the case on a two button mouse?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

说不完的你爱 2024-10-16 05:31:18

为了避免任何歧义,请使用 SwingUtilities :

SwingUtilities.isLeftMouseButton(MouseEvent anEvent)
SwingUtilities.isRightMouseButton(MouseEvent anEvent)
SwingUtilities.isMiddleMouseButton(MouseEvent anEvent)

To avoid any ambiguity, use the utilities methods from SwingUtilities :

SwingUtilities.isLeftMouseButton(MouseEvent anEvent)
SwingUtilities.isRightMouseButton(MouseEvent anEvent)
SwingUtilities.isMiddleMouseButton(MouseEvent anEvent)

揪着可爱 2024-10-16 05:31:18

是的,看看这个讨论平台之间差异的帖子。

如何检测 Mac 操作系统的右键单击事件

BUTTON3 在所有平台上都是相同的,相当于鼠标右键。如果中间按钮不存在,则 BUTTON2 将被忽略。

Yes, take a look at this thread which talks about the differences between platforms.

How to detect right-click event for Mac OS

BUTTON3 is the same across all platforms, being equal to the right mouse button. BUTTON2 is simply ignored if the middle button does not exist.

爱人如己 2024-10-16 05:31:18

我以前见过

anEvent.isPopupTrigger() 

用过。我对 Java 还很陌生,所以我很高兴听到关于这种方法的想法:)

I've seen

anEvent.isPopupTrigger() 

be used before. I'm fairly new to Java so I'm happy to hear thoughts about this approach :)

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