问题描述
我使用 public boolean mouseDown(Event ev,int x,int y)
来检测鼠标的点击。
我可以区分鼠标右键(ev.metaDown()为true)和左侧和中部。
I use public boolean mouseDown(Event ev, int x, int y)
to detect a click of the mouse.
I can distinguish between the right mouse button (ev.metaDown() is true) and the left and middle.
我如何区分左侧的中间按钮?
或者如果mouseDown不可能,应该使用什么?
How can i differentiate the left from the middle button?Or if it is impossible with mouseDown, what should i use?
推荐答案
尝试使用:
所以你的代码可能是:
if (ev.modifiers & Event.ALT_MASK != 0) {
// middle button was pressed
}
当然,这一切假设你有一个很好的理由首先使用mouseDown,因为它已被弃用。你应该(可能)使用,这样可以让您使用MouseEvent来玩。
Of course, all this is assuming you have a very good reason to use mouseDown in the first place, since it is deprecated. You should (probably) be using processMouseEvent instead, which gives you a MouseEvent to play with.
这篇关于如何在java中获取鼠标中键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!