LWJGL Forum

Programming => General Java Game Development => Topic started by: code_monster on July 29, 2010, 02:52:04

Title: Mouse events and Set focus
Post by: code_monster on July 29, 2010, 02:52:04
Hello I am using an older version of Lwjgl.  I believe it is version 2.3.  I am having problems with the mouse events not firing on a mac whereas they do fire on a pc in windowed mode.   On a mac, if the main window does not focus then mouse move events do not fire when the mouse is over the main window.  Also, while the main window doesn't have focus, the left mouse click will set the focus on it the but does not update the mouse position and the right click does not even set the focus nor update the position.  Interestingly enough, if you move the right mouse while the right button is held then mouse positions are updated.  This is rather odd behavior and can be duplicated with the MouseTest demo on the demos page. 

Is this expected on a mac?  If so is there a way that I can set the focus back to this main window and get the current position of the mouse?
Title: Re: Mouse events and Set focus
Post by: kappa on July 29, 2010, 10:06:35
...
Is this expected on a mac?  If so is there a way that I can set the focus back to this main window and get the current position of the mouse?

Funny you'd mention this just now since we were just discussing this over at #lwjgl a few days ago.

Now the issue here is that Mac's use a Java AWT Frame to create their LWJGL Display window.  The problem here seems to be with how the AWT Frame works on mac, if it doesn't have focus it doesn't receive any mouse events. However an AWT Frame on windows and linux works just fine and receives mouse events even when Frame is not focused.

I'm not really sure what the LWJGL team can do here since this appears to be an issue with AWT on mac.

A possible solution would be to write a native window system for LWJGL like linux and windows have, however this is no small task and would require an almost complete rewrite of the mac support for LWJGL. If anyones up for this task feel free to attempt it, this would also be very useful in many other respects too.