Skip to content

Instantly share code, notes, and snippets.

@GoodBoyNinja
Last active November 17, 2023 22:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GoodBoyNinja/c14c8f710956f18b2af49d0c947d6a16 to your computer and use it in GitHub Desktop.
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(), …
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