I am making a drag and drop application with the Google Closure javascript library.
How do I detect the current position of the mouse in a dragover event?
var dragOverCallBack = function (e) {
console.log(e.somehowGetMouseXPosition());
}
I have tried e.clientX
and e.pageX
to no avail (both are undefined).
I'm not sure why e.clientX and e.pageX would be undefined unless e is being passed as undefined, which would mean your callback is not set up properly. I would try running running console.debug(e) in your callback and looking at the object in chrome's developer tools console. It might offer some insight into the event object that is being passed to you.
Aside from e.clientX and e.pageX, various other options exist which offer mouse coordinates for different uses (e.offsetX, e.screenX, etc) This article covers these different coordinates quite well. You could try some of these to see if you can get anything.