From d7c3c87d992924e6fc4f21a3da95ab992c43d905 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 13 Sep 2020 13:43:38 -0400 Subject: Mouse button modifier update (#824) * Ensure buttons is positive before adding to set * Break early when there are no flags remaining --- ext/mixed/js/document-util.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/mixed/js/document-util.js b/ext/mixed/js/document-util.js index 58b0c759..d448fc3c 100644 --- a/ext/mixed/js/document-util.js +++ b/ext/mixed/js/document-util.js @@ -312,12 +312,14 @@ class DocumentUtil { } static _getActiveButtons(event, set) { - const {buttons} = event; - if (typeof buttons === 'number') { + let {buttons} = event; + if (typeof buttons === 'number' && buttons > 0) { for (let i = 0; i < 6; ++i) { const buttonFlag = (1 << i); if ((buttons & buttonFlag) !== 0) { set.add(`mouse${i}`); + buttons &= ~buttonFlag; + if (buttons === 0) { break; } } } } -- cgit v1.2.3