Keeping the mouse inside the window

Started by TInychan, October 25, 2011, 08:43:24

Previous topic - Next topic

TInychan

Halfway through making a TD game, realized I couldn't keep the mouse inside the window for scrolling the map, tried getting mouse position and setting it if it's less than some value but it looks bad and if you move fast enough you can bypass it

Any way to prevent the mouse from leaving the window entirely? (in windowed, nonfullscreen mode)

kappa


TInychan

Is there one that doesn't hide the cursor?

Matzon


CodeBunny

To be fair, it would be nice if there was a separate method setVisible() controlling hiding the mouse.

princec

You can already do this by setting the cursor shape to something entirely transparent, using either the LWJGL methods, or the same trick in AWT if using Display.setParent(). Admittedly a utility method to do this for you would be nice.

Cas :)

CodeBunny

By nice I mean it would be more of a simple, clean API.