我试图在按住左键时将布尔值设为真,当我没有左键时将其设为假,我正在尝试使用“Jnativehook”鼠标监听器”(https://github.com/kwhat/jnativehook/wiki /Mouse ) 但布尔值没有改变。
代码:
package me.ordinals;
import org.jnativehook.mouse.*;
import java.awt.event.InputEvent;
public class mouseHandler implements NativeMouseListener {
@Override
public void nativeMouseClicked(NativeMouseEvent nativeMouseEvent) {
}
@Override
public void nativeMousePressed(NativeMouseEvent nativeMouseEvent) {
if (nativeMouseEvent.getButton() == InputEvent.BUTTON1_DOWN_MASK) {
ac.getInstance().setToggled(true);
}
}
@Override
public void nativeMouseReleased(NativeMouseEvent nativeMouseEvent) {
if (nativeMouseEvent.getButton() == InputEvent.BUTTON1_DOWN_MASK) {
ac.getInstance().setToggled(false);
}
}
}