Hello Guest

[FIXED] Mouse.isbuttondown not updating correctly

  • 56 Replies
  • 50804 Views
[FIXED] Mouse.isbuttondown not updating correctly
« on: May 21, 2009, 10:07:28 »
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?
« Last Edit: January 13, 2011, 12:30:39 by Mickelukas »

Re: Mouse.isbuttondown not updating correctly
« Reply #1 on: May 21, 2009, 13:16:06 »
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.

Re: Mouse.isbuttondown not updating correctly
« Reply #2 on: May 21, 2009, 15:01:00 »
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.

Re: Mouse.isbuttondown not updating correctly
« Reply #3 on: May 23, 2009, 11:58:49 »
No workaround/solution for this? What about the possibility to catch the mouseevents from java seeing as they have mouse entered and mouse exited?

*

Offline kappa

  • *****
  • 1313
Re: Mouse.isbuttondown not updating correctly
« Reply #4 on: May 23, 2009, 14:40:03 »
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

Re: Mouse.isbuttondown not updating correctly
« Reply #5 on: May 23, 2009, 17:15:08 »
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?

*

Offline kappa

  • *****
  • 1313
Re: Mouse.isbuttondown not updating correctly
« Reply #6 on: May 23, 2009, 17:27:22 »
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.
« Last Edit: May 23, 2009, 17:31:18 by javalwjgl »

*

Offline Matzon

  • *****
  • 2242
Re: Mouse.isbuttondown not updating correctly
« Reply #7 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 ?

*

Offline kappa

  • *****
  • 1313
Re: Mouse.isbuttondown not updating correctly
« Reply #8 on: May 23, 2009, 18:24:22 »
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.

Re: Mouse.isbuttondown not updating correctly
« Reply #9 on: May 23, 2009, 20:07:05 »
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.

Re: Mouse.isbuttondown not updating correctly
« Reply #10 on: May 25, 2009, 07:55:45 »
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.
« Last Edit: May 25, 2009, 07:57:18 by Mickelukas »

Re: Mouse.isbuttondown not updating correctly
« Reply #11 on: May 27, 2009, 09:33:19 »
Still no clue about this one?

*

Offline Matzon

  • *****
  • 2242
Re: Mouse.isbuttondown not updating correctly
« Reply #12 on: May 27, 2009, 09:36:30 »
I comitted a fix yesterday. Nightly failed (missing import) but hopefully it should all be good tonight - pending tests.

Re: Mouse.isbuttondown not updating correctly
« Reply #13 on: May 27, 2009, 11:27:25 »
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 :)

*

Offline Matzon

  • *****
  • 2242
Re: Mouse.isbuttondown not updating correctly
« Reply #14 on: May 27, 2009, 13:12:52 »
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.