LWJGL hide cursor

I’m trying to make camera movement when pressing the right mouse button down and moving the mouse. When the button is down, I want the cursor to be hidden:

if( InputHandler.isButtonDown( InputHandler.MOUSE_RIGHT ) ) {
	GLFW.glfwSetInputMode( ExampleGame.display.getWindowID( ),GLFW.GLFW_CURSOR,GLFW.GLFW_CURSOR_HIDDEN );
	// move camera (working but I left it out)
} else {
	GLFW.glfwSetInputMode( ExampleGame.display.getWindowID( ),GLFW.GLFW_CURSOR,GLFW.GLFW_CURSOR_NORMAL );
}

But it only works when I let the second glfwSetInputMode in the else statement out and that means that the mouse stays hidden!
What happens with the above code, is that the mouse hides for about a frame when pressing the right mouse button and the reappears because the else statement gets activated. But why does the hide cursor only work when I let the mouse button go? Everything else works directly when pressing it…

If [icode]InputHandler.isButtonDown(InputHandler.MOUSE_RIGHT)[/icode] returns [icode]false[/icode] while you are still holding down the right mouse button, then what does it tell you…?

So, what does this method actually do besides not checking whether a certain mouse button is down?

By the end of the day, all in all this should happen:


glfwSetMouseButtonCallback(window, mouseButtonCallback = new GLFWMouseButtonCallback() {
    public void invoke(long window, int button, int action, int mods) {
        if (action == GLFW_PRESS && button == GLFW_MOUSE_BUTTON_RIGHT) {
            glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
        } else if (action == GLFW_RELEASE && button == GLFW_MOUSE_BUTTON_RIGHT) {
            glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
        }
    }
});

I don’t know exactly what you want? isButtonDown() returns true while this button is held down…
And yes, I use a GLFWButtonCallback in the background, similar to what you showed. I do it in an extra class, because it has other useful methods like isButtonPressed() that only returns true once, until the button is pressed down again…

Look:
From the information/descriptions you gave so far…

[quote]What happens with the above code, is that the mouse hides for about a frame when pressing the right mouse button and the reappears because the else statement gets activated.
[/quote]
…I could only conclude that [icode]InputHandler.isButtonDown()[/icode] does not return [icode]true[/icode] for as long as you hold down the right mouse button, because otherwise the else case would not have gotten executed. And we can also conclude that you execute the given code snippet per frame.

So, maybe that method behaves [quote]like isButtonPressed() that only returns true once, until the button is pressed down again
[/quote]
?

No, I already debugged it. :frowning:
It works correctly