kasper / phoenix

A lightweight macOS window and app manager scriptable with JavaScript
https://kasper.github.io/phoenix/
Other
4.38k stars 127 forks source link

Add modifier flags for mouse events #217

Closed DanielGibbsNZ closed 5 years ago

DanielGibbsNZ commented 6 years ago

This adds modifier flags for mouse events (fixes #216), allowing you to do things like this (which would be useful for when I lose my mouse cursor):

// If I Cmd+Alt+Click, centre my mouse cursor on the main screen.
var handler = new Event('mouseDidLeftClick', function (event) {
    if (_.includes(event.modifiers, 'cmd') && _.includes(event.modifiers, 'alt')) {
        var mainScreen = Screen.all()[0];
        var mainScreenFrame = mainScreen.frame();
        var middle = { 
            x: mainScreenFrame.x + mainScreenFrame.width / 2,
            y: mainScreenFrame.y + mainScreenFrame.height / 2,
        };
        Mouse.move(middle);
    }
});
kasper commented 6 years ago

Thanks! I will review this with more thought later.

izanagi1995 commented 6 years ago

Bump, LGTM

DanielGibbsNZ commented 5 years ago

Any chance of this getting merged soon?

kasper commented 5 years ago

@DanielGibbsNZ Thanks for the contribution and sorry for the long wait! Merged and this feature is now in build 76.