higgsjs / Higgs

Higgs JavaScript Virtual Machine
875 stars 62 forks source link

draw lib onMouseDown, onMouseUp, and button recognition. #195

Closed bFraley closed 9 years ago

bFraley commented 9 years ago

These commits implement window.onMouseDown window.onMouseUp and expose a button variable to onClick, onMouseDown, and onMouseUp.

button returns either "left" "right" "center" "wheelUp" or "wheelDown"

Pseudo Usage:

window.onMouseDown(function(canvas, mouseX, mouseY, button)
{
    if (button === "left")
    {
        shootTheMoon = true;
        shoot(mouseX, mouseY);
    }
    else if (button === "right")
        displayOptions = true;

    else if (button === "wheelUp")
        moveForward = true;    
});
maximecb commented 9 years ago

Awesome! :)

Another nitpick: could you rename leftClick, centerClick, rightClick to just left, right, center?

bFraley commented 9 years ago

@maximecb Let me know if this works for you, and any other changes you have in mind.

maximecb commented 9 years ago

Works fine. Thank you for your great work, this is really good news for Higgs :)