Mouse exited event for Drawable?

Started by fazekaim, August 18, 2009, 21:57:39

Previous topic - Next topic

fazekaim

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.

Rene

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.
When I am king, they shall not have bread and shelter only, but also teachings out of books, for a full belly is little worth where the mind is starved - Mark Twain

Matzon


Matzon

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)

fazekaim

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...

Matzon

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.

kappa

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.

fazekaim

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?

Matzon

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.

fazekaim

"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!

Matzon

if youre running fullscreen just check that mouse is at edge... in windowed mode check that its near the border too