Skip to content

Instantly share code, notes, and snippets.

@GoodBoyNinja
Last active June 7, 2021 21:11
Embed
What would you like to do?
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(), …
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