aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed/js/document-util.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mixed/js/document-util.js')
-rw-r--r--ext/mixed/js/document-util.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/ext/mixed/js/document-util.js b/ext/mixed/js/document-util.js
index 0b72ff9a..58b0c759 100644
--- a/ext/mixed/js/document-util.js
+++ b/ext/mixed/js/document-util.js
@@ -188,6 +188,18 @@ class DocumentUtil {
return modifiers;
}
+ static getActiveModifiersAndButtons(event) {
+ const modifiers = this.getActiveModifiers(event);
+ this._getActiveButtons(event, modifiers);
+ return modifiers;
+ }
+
+ static getActiveButtons(event) {
+ const buttons = new Set();
+ this._getActiveButtons(event, buttons);
+ return buttons;
+ }
+
static getKeyFromEvent(event) {
const key = event.key;
return (typeof key === 'string' ? (key.length === 1 ? key.toUpperCase() : key) : '');
@@ -299,6 +311,19 @@ class DocumentUtil {
return !(browser === 'firefox' || browser === 'firefox-mobile') || os === 'mac';
}
+ static _getActiveButtons(event, set) {
+ const {buttons} = event;
+ if (typeof buttons === 'number') {
+ for (let i = 0; i < 6; ++i) {
+ const buttonFlag = (1 << i);
+ if ((buttons & buttonFlag) !== 0) {
+ set.add(`mouse${i}`);
+ }
+ }
+ }
+ return set;
+ }
+
// Private
_setImposterStyle(style, propertyName, value) {