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.
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.
this should be fixed in 2.2
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)
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...
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.
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.
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?
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.
"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!
if youre running fullscreen just check that mouse is at edge... in windowed mode check that its near the border too