diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-09-09 16:59:03 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-09 16:59:03 -0400 |
commit | 0d00f7e1cf8a0fa1e2b1aa2732bceaae39f4e23c (patch) | |
tree | 92b0a2e72ef2cecb31e8cc70da354ee43b87e2b4 /ext/mixed/js/document-util.js | |
parent | acb7ad32f39c40b879400c9daa4bc8cd25585ba7 (diff) |
Scanning input generalization (#789)
* Add inputs to options.scanning
* Update CSS for mouse buttons
* Update list counters
* Set up HTML/CSS
* Add input controller
* Use new inputs
* Include mouse buttons
* Update how button inputs are detected
* Add index/empty fields to the input details object
* Update none check for scanning modifier
* Remove old settings
* Remove unused global
Diffstat (limited to 'ext/mixed/js/document-util.js')
-rw-r--r-- | ext/mixed/js/document-util.js | 25 |
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) { |