[Solved] Get mouse position outside browser window?


I’m looking for a way to get the mouse position, that continues to work when the mouse leaves the browser window.

On all OpenFL examples I can find to get the mouse position the function stop working when the mouse leaves the browser window.

Thanks in advance!

I don’t think there’s any browser/JavaScript engine that makes mouse events accessible outside the browser document area.

You can give Slip.js and touch events a try by adding listeners to OpenFL’s canvas element, as it looks like it registers touch movements outside the browser window to a limited extent (but only after a touch/tap has been made)

Thanks, I managed to get it working by adding a mouse move event listener to js.Browser.document instead of an openfl MouseEvent listener on the stage.

1 Like