Mouse position tracking outside HTML5 Canvas

  • Hello,

    I have some adjustment dials (rotating knobs) which are adjusted by mouse dragging. On HTML5 windowed target mouse position outside Canvas is not updated (reading mouse.x or mouse.screenX). What should I do to get that position? Flash can do it and as far as I can tell pure HTML5 js also can. Is this implemented in HaxeFlixel?

  • To clarify:
    Compile target: HTML5 fixed size window in a browser on Desktop
    Problem: After pressing left mouse button in canvas area user drags mouse to position/change certain elements on canvas. It should be done in whole browser window even when mouse pointer leaves canvas element.

    I did find solution at least for mouse position, not sure yet about onmouseup. And it continues to register events (FlxG.log.add) even when focus of the browserwindow is lost. This should be takencare of.
    If someone is interested:

    #if html5
    import js.Browser;

    Browser.document.onmousemove = DOMmouseMove;

    public function DOMmouseMove(e:Dynamic)
    // Here you can register e.screenX, e.pageX, e.clientX ... in whole Browser window
    // Since I need relative mouse position while dragging, any of these are good for me (some of them change direction on multi monitor setup)

Log in to reply

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.