Linux中的Java弹出触发器 [英] Java popup trigger in Linux

查看:109
本文介绍了Linux中的Java弹出触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,您可以在其中执行鼠标右键单击和拖动(以及进行不同操作的左键单击和拖动).但是,在Linux上运行此命令时,似乎弹出菜单是由mousePressed而不是mouseReleased触发的.导致每次我按下鼠标右键进行拖动时,都会触发弹出菜单(与窗口不同,它是mouseReleased的窗口).

I have an application in which you can do a right mouse button press and drag (as well as a left press and drag for different operations). However, when running this on linux, it seems that popup menus are triggered by a mousePressed and not a mouseReleased. This is resulting in every time I press the right mouse button to perform a drag, the popup menus are triggered (unlike windows, where it is mouseReleased).

关于如何解决此问题的任何想法?

Any thoughts on how to work around this?

谢谢.

发布代码

弹出菜单代码

// this is called from mousePressed and mouseReleased
if (e.isPopupTrigger() && !e.isConsumed()) {
    // show the popup menu
}

此代码是在鼠标右键单击/拖动时所调用的代码(这是第三方代码,但它是开放源代码,因此我可以根据需要进行更改)

This code is what is called on the right mouse press/drag (this is 3rd party code, but it is open source so I can change as needed)

// this is called on all mouse events
if (buttonAction.mouseButton != 0)
{
    // handle the event
}

推荐答案

是的,使用isPopupTrigger(),如下所示

Yes, use isPopupTrigger(), as shown here.

附录:

它似乎是isPopupTrigger在Linux中的mousePressed上触发的.

it appears isPopupTrigger is triggered on mousePressed in linux.

是的,在Mac OS X上是相同的.您必须同时从mousePressed()mouseReleased()调用isPopupTrigger(). GraphPanel .

Yes, it's the same on Mac OS X. You have to call isPopupTrigger() from both mousePressed() and mouseReleased(). There's a related example in GraphPanel.

这篇关于Linux中的Java弹出触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆