LWJGL Forum

Programming => OpenGL => Topic started by: fazekaim on August 18, 2009, 21:57:39

Title: Mouse exited event for Drawable?
Post by: fazekaim on August 18, 2009, 21:57:39
Hello,

my game has scrolling functionality at the edges and corners of the window. How can i handle the exiting of the mouse from the rectangle of the window?
i don't know how can prepare my code for that. Any help is much appreciated.
Title: Re: Mouse exited event for Drawable?
Post by: Rene on August 18, 2009, 22:03:12
I'm not sure if this is the best way, but the first thing I can think of is to make the 'scroll area' a few rows / columns of pixels, not only the first and last row / col. Then, you keep track of the last known mouse position. If the mouse exits the window, this value will not be updated and therefore will be still in the 'scroll area'. In every update of the game you check the mouse position you saved yourself, and scroll accordingly.
Title: Re: Mouse exited event for Drawable?
Post by: Matzon on August 18, 2009, 22:05:19
this should be fixed in 2.2
Title: Re: Mouse exited event for Drawable?
Post by: Matzon on August 19, 2009, 06:48:37
yo follow up on this - mouse drag events will continue outside the window until you release the button. so you can just check that the values are inside the bounds of the window (or delta values change)
Title: Re: Mouse exited event for Drawable?
Post by: fazekaim on August 19, 2009, 07:39:31
You mean, when dragging ...
Actually, the scrolling doesn't require mouse button pressure but to move the curzor to one of the edges or corners of the window.
So, what if i define the frame at pixels 1, screensize-1 and all mouse moving at this positions means mouse exiting?
Until the 2.2 will be published...
Title: Re: Mouse exited event for Drawable?
Post by: Matzon on August 19, 2009, 10:45:00
I am not sure how you would handle that case - but there is no mouse exit event, since there are no events in the lwjgl input handling.
Title: Re: Mouse exited event for Drawable?
Post by: kappa on August 19, 2009, 10:59:58
you could just grab the mouse? and release it on the escape key, that way you won't have the problem of it leaving the window when trying to scroll.
Title: Re: Mouse exited event for Drawable?
Post by: fazekaim on August 19, 2009, 11:18:33
I am not sure how you would handle that case --- well, i was wondering if in my mouse handler when the cursor reached the scroll area, i can test if the mouse cursor is right at the edges of the screen, in this case i can fire a custom mouseexited event.
I know with fast mouse motion this doesn't work, but better than nothing.

So 2.2 wil contains mouseexited and mouseentered event?
Title: Re: Mouse exited event for Drawable?
Post by: Matzon on August 19, 2009, 12:20:01
What you describe is how I would handle it.
There are no mouse-enter/exit - but we have added support for mouse drag generating x/y outside the window, until you release the button.
Title: Re: Mouse exited event for Drawable?
Post by: fazekaim on August 19, 2009, 20:14:36
"What you describe is how I would handle it." --- :) bad news that fast mouse motion cannot be handled with the process i desribed. no mouse event occurs in that position.

"There are no mouse-enter/exit - but we have added support for mouse drag generating x/y outside the window, until you release the button." --- my problem is that scrolling on the map in the game requires only mouse motion no button pressing is required :(

Thanks anyway!
Title: Re: Mouse exited event for Drawable?
Post by: Matzon on August 19, 2009, 22:39:18
if youre running fullscreen just check that mouse is at edge... in windowed mode check that its near the border too