简体   繁体   English

确定LWJGL中的鼠标按钮释放

[英]Determine mouse button release in LWJGL

I have a program in LWJGL where I have a series of buttons. 我在LWJGL中有一个程序,其中有一系列按钮。 I'm trying to use Mouse.getEventButton() and Mouse.getEventButtonState() in order to figure out when the mouse is released , but neither seem to be working. 我试图使用Mouse.getEventButton()Mouse.getEventButtonState()来确定释放鼠标的时间,但似乎都无法正常工作。 After adding a few print statements for debugging, it seems that getEventButton() always returns 0 regardless of what the mouse is doing, and getEventButtonState() always returns false. 添加了一些用于调试的打印语句后,无论鼠标在做什么,似乎getEventButton()始终返回0,而getEventButtonState()始终返回false。 All other mouse methods I've used so far have behaved normally. 到目前为止,我使用的所有其他鼠标方法都表现正常。 Any idea what might be going on? 知道会发生什么吗?

It can be done by analogy with keyboard as described in this tutorial . 本教程中所述可以通过类比键盘来完成。

while (Mouse.next()){
    if (Mouse.getEventButtonState()) {
        if (Mouse.getEventButton() == 0) {
            System.out.println("Left button pressed");
        }
    }else {
        if (Mouse.getEventButton() == 0) {
            System.out.println("Left button released");
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM