diff --git a/src/io/mouse.js b/src/io/mouse.js index 47c6a498..508248d0 100644 --- a/src/io/mouse.js +++ b/src/io/mouse.js @@ -5,6 +5,7 @@ class Mouse { this._x = 0; this._y = 0; this._buttons = new Set(); + this.usesRightClickDown = false; this._isDown = false; /** * Reference to the owning Runtime. @@ -156,6 +157,9 @@ class Mouse { * @return {boolean} Is the mouse button down? */ getButtonIsDown (button) { + if (button === 2) { + this.usesRightClickDown = true; + } return this._buttons.has(button); } } diff --git a/test/unit/io_mouse.js b/test/unit/io_mouse.js index d9966123..d672bc08 100644 --- a/test/unit/io_mouse.js +++ b/test/unit/io_mouse.js @@ -108,7 +108,7 @@ test('mouseDown with buttons', t => { t.end(); }); -test('no button is treated as left', t => { +test('missing button is treated as left', t => { const rt = new Runtime(); const m = new Mouse(rt); @@ -124,6 +124,16 @@ test('no button is treated as left', t => { t.end(); }); +test('usesRightClickDown', t => { + const rt = new Runtime(); + const m = new Mouse(rt); + + t.strictEquals(m.usesRightClickDown, false); + t.strictEquals(m.getButtonIsDown(2), false); + t.strictEquals(m.usesRightClickDown, true); + t.end(); +}); + test('at zoomed scale', t => { const rt = new Runtime(); const m = new Mouse(rt);