Last active
November 17, 2023 22:26
-
-
Save GoodBoyNinja/c14c8f710956f18b2af49d0c947d6a16 to your computer and use it in GitHub Desktop.
a mouse object for ExtendScript. This creates a new object called mouse which you can manually (only) update to keep track of your clicks. For example, on a right click you can use Mouse.setRight() to set the "last" property to 2 (mouse button of index 2). Then you can check if your latest click was a right click by calling Mouse.lastIsRight(), …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Mouse = new (function () { | |
var mouse = this; | |
this.last = 0; | |
this.setLeft = function () { | |
mouse.last = 0; | |
}; | |
this.setMiddle = function () { | |
mouse.last = 1; | |
}; | |
this.setRight = function () { | |
mouse.last = 2; | |
}; | |
this.set = function (num) { | |
switch (num) { | |
case 0: | |
mouse.setLeft(); | |
break; | |
case 1: | |
mouse.setMiddle(); | |
break; | |
case 2: | |
mouse.setRight(); | |
break; | |
} | |
}; | |
this.lastIsLeft = function () { | |
return mouse !== null && mouse.last == 0; | |
}; | |
this.lastIsRight = function () { | |
return mouse !== null && mouse.last == 2; | |
}; | |
this.lastIsMiddle = function () { | |
return mouse !== null && mouse.last == 1; | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment