[FIXED] Mouse.isbuttondown not updating correctly

Started by Mickelukas, May 21, 2009, 10:07:28

Previous topic - Next topic

Mickelukas

Hi there,

If I hold down a mouse button while moving the mouse outside my applet Mouse.isbuttondown still returns true even if I release the mouse. If I after that move the mouse back inside the applet it still says that the mouse button is down even though it isn't.

I could make a workaround for it if there was a function to check whether or not the mouse is inside the applet but the Mouse class doesn't have that functionality.

Any ideas?

Ciardhubh

It's probably an OS/driver restriction you have to handle yourself. If the mouse is outside the window, the OS most likely doesn't send events to the application. Lots of game engines have trouble with input when loosing focus.

Mickelukas

Standard windows driver and windows xp. Probably the most common combination there is.

I could fix it if I were able to add the standard java mouselistener to the applet but when I do it doesn't get any events at all.

Mickelukas

No workaround/solution for this? What about the possibility to catch the mouseevents from java seeing as they have mouse entered and mouse exited?

kappa

as with the above mentioned post this behaviour only happens with windows, what most games do to get round this is they grab the mouse Mouse.setGrabbed(true) or Mouse.setCursorPosition(middleOfScreenX, middleOfScreenY), so it can't leave the window, an example of this behaviour can be seen at http://www.minecraft.net

Mickelukas

Well, half or so of my game is played outside the applet and half inside meaning that you will need to be able to move the mouse outside of the applet.

Is there no workaround to access the java mouse listener?

kappa

you can't really use the java mouse listener since LWJGL's Display is not an AWT/Swing component. You could use LWJGL's AWTGLCanvas container but then you would loose significant performance.

You could also use the AWT Robot but then this would require signed permissions.

one thing that comes to mind is that you could use javascript to detect if the mouse is outside the applet, that way you can alert the applet using using liveconnect.

Matzon

It still sounds like something that lwjgl may be able to handle - but is it a windows only issue ?

kappa

can't speak for mac or solaris, but linux correctly detects mouse button release when outside the applet Display, while on windows it does not.

Mickelukas

Quote from: javalwjgl on May 23, 2009, 17:27:22
one thing that comes to mind is that you could use javascript to detect if the mouse is outside the applet, that way you can alert the applet using using liveconnect.

This was how I was going to solve it if it wasn't possible for you guys to see what causes it. I don't like that kind of workaround though seeing as it brings alot of combinations of webbrowsers/OS' that might cause problems.

Mickelukas

Quote from: Matzon on May 23, 2009, 17:54:32
It still sounds like something that lwjgl may be able to handle - but is it a windows only issue ?

Did you get an epiphany regarding this issue? :) If it would be possible to get it fixed in 2.2 then I don't have any more open issues after my merge from JOGL to LWJGL.

Mickelukas


Matzon

I comitted a fix yesterday. Nightly failed (missing import) but hopefully it should all be good tonight - pending tests.

Mickelukas

Cool :) If you get rid of the security alert and release 2.2 I'll definately donate some money as thanks for all the bug fixing :)

Matzon

well, it seems that there are some issues still - so need to look at bit on that - not sure if I have time tonight tho...
lwjgl 2.2 will happen eventually - but the certificate stuff is out of my hands, and moving at an invisible snails pace.