How to hide a mouse cursor when a button is pressed?

Hello,



I am using the ChaseCamera in my simple game and I have set it to perform a mouse look when the left button is pressed:


ChaseCamera chaser = new ChaseCamera(cam, player, props);
chaser.getMouseLook().setLookMouseButton(0);



I am also using an AbsoluteMouse registered with my input handler to display my own mouse cursor.

Now I would like to make the cursor invisible when the left button is pressed and make it reappear when it is released. Is there an easy way to do it?

Thanks.
Filip

This is kind of an old thread, but since it wasn't answered…the short answer to that is "Yes".



Use


org.lwgl.input.Mouse.setGrabbed(pressed);


where pressed is true/false in your mouse handler.  "Mouse" is "org.lwgl.input.Mouse", so don't get it confused with com.jme.input.Mouse (I updated the code to use the absolute class).