Jump to content

How to list the mouse move events ?


gsoucy

Recommended Posts

Hello,

 

I read that there is no way to get the current mouse position (but this is really what I am after ultimately).

 

However, is it possible to get the list of events currently in the stack of events ? In other words, is there a way to actively pull the next events without waiting for the system to call the corresponding callback. I would like to skip all past mouse position events to go to the most recent one and process only this one. But how to know that there are no more at a given moment ?

 

In last resort, is there a way to even know that there are more events waiting in the stack of events? Can we know the number of events in the stack while we are processing another one ?

 

Thanks

 

Gilbert

Link to comment
Share on other sites

Actually, I thought that screenx and screeny would give the mouse position at moment the event was generated, not now. I was wrong ?

That's right, they give the position of the mouse when the mousemove event fired, which is the last time they moved the mouse. If the mouse isn't moving then the event won't fire, it fires every time they move the mouse and you can use the event handler to call a function with the new position or do whatever you want. You can save it in a global variable if you want to access it at some point when the mouse isn't moving.If you're trying to get the position of the mouse when the page loads before it has moved, according to that Stack Overflow thread it sounds like the mouseenter event fires on page load with the coordinates, but only if the mouse is actually over the page. The mouse might not even be over the browser when the load event fires.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...