event.pageY
gets you the mouse position relative to the entire document height(document.documentElement.offsetHeight
I assume).
But how do I get the mouse position relative to the current viewport, which is document.documentElement.clientHeight
?
For example, if the browser window size has a 720 pixel height, I scroll down 3 pages and keep the mouse in the middle of the window, the position should be "360", not 1800 (720 x 3 - 720 / 2).
In Mouse Properties, on the Pointer Options tab, at the bottom, select Show location of pointer when I press the CTRL key, and then select OK.
To set or get the position of the mouse cursor use the static methods QCursor::pos() and QCursor::setPos().
You can't move the mouse pointer using javascript, and thus for obvious security reasons. The best way to achieve this effect would be to actually place the control under the mouse pointer. The security implications are far from obvious.
Try using event.clientY
that should always return the correct value regardless of scrolling
https://developer.mozilla.org/en-US/docs/DOM/event.clientY
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With