Hello Guest

Mouse exited event for Drawable?

  • 10 Replies
  • 7927 Views
Mouse exited event for Drawable?
« 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.

*

Offline Rene

  • **
  • 78
Re: Mouse exited event for Drawable?
« Reply #1 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.
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

*

Offline Matzon

  • *****
  • 2242
Re: Mouse exited event for Drawable?
« Reply #2 on: August 18, 2009, 22:05:19 »
this should be fixed in 2.2

*

Offline Matzon

  • *****
  • 2242
Re: Mouse exited event for Drawable?
« Reply #3 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)

Re: Mouse exited event for Drawable?
« Reply #4 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...

*

Offline Matzon

  • *****
  • 2242
Re: Mouse exited event for Drawable?
« Reply #5 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.

*

Offline kappa

  • *****
  • 1316
Re: Mouse exited event for Drawable?
« Reply #6 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.

Re: Mouse exited event for Drawable?
« Reply #7 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?

*

Offline Matzon

  • *****
  • 2242
Re: Mouse exited event for Drawable?
« Reply #8 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.

Re: Mouse exited event for Drawable?
« Reply #9 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!

*

Offline Matzon

  • *****
  • 2242
Re: Mouse exited event for Drawable?
« Reply #10 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