LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: TInychan on October 25, 2011, 08:43:24

Title: Keeping the mouse inside the window
Post by: TInychan on October 25, 2011, 08:43:24
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)
Title: Re: Keeping the mouse inside the window
Post by: kappa on October 25, 2011, 09:07:56
Mouse.setGrabbed(true);
Title: Re: Keeping the mouse inside the window
Post by: TInychan on October 26, 2011, 05:29:13
Is there one that doesn't hide the cursor?
Title: Re: Keeping the mouse inside the window
Post by: Matzon on October 26, 2011, 08:11:29
render your own cursor?
Title: Re: Keeping the mouse inside the window
Post by: CodeBunny on October 26, 2011, 12:08:37
To be fair, it would be nice if there was a separate method setVisible() controlling hiding the mouse.
Title: Re: Keeping the mouse inside the window
Post by: princec on October 27, 2011, 08:45:30
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 :)
Title: Re: Keeping the mouse inside the window
Post by: CodeBunny on October 27, 2011, 12:02:46
By nice I mean it would be more of a simple, clean API.