Jump to content
Sign in to follow this  
gsoucy

How to list the mouse move events ?

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...