aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/settings/keyboard-mouse-input-field.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-09-11 16:57:57 -0400
committerGitHub <noreply@github.com>2020-09-11 16:57:57 -0400
commita5845df123f4024db686d21c4f37f38be79fb8e5 (patch)
tree564efed3557fb237b595cefb418a65b5930a2538 /ext/bg/js/settings/keyboard-mouse-input-field.js
parent6afbda8dfe6451420b031fa376798610d48a389b (diff)
Add support for pointer event input detection (#810)
Diffstat (limited to 'ext/bg/js/settings/keyboard-mouse-input-field.js')
-rw-r--r--ext/bg/js/settings/keyboard-mouse-input-field.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/ext/bg/js/settings/keyboard-mouse-input-field.js b/ext/bg/js/settings/keyboard-mouse-input-field.js
index 4ba0d3ed..2c6a6476 100644
--- a/ext/bg/js/settings/keyboard-mouse-input-field.js
+++ b/ext/bg/js/settings/keyboard-mouse-input-field.js
@@ -20,10 +20,11 @@
*/
class KeyboardMouseInputField extends EventDispatcher {
- constructor(inputNode, mouseButton, os) {
+ constructor(inputNode, mouseButton, os, isPointerTypeSupported=null) {
super();
this._inputNode = inputNode;
this._mouseButton = mouseButton;
+ this._isPointerTypeSupported = isPointerTypeSupported;
this._keySeparator = ' + ';
this._inputNameMap = new Map(DocumentUtil.getModifierKeys(os));
this._keyPriorities = new Map([
@@ -54,6 +55,7 @@ class KeyboardMouseInputField extends EventDispatcher {
if (type === 'modifierInputs' && this._mouseButton !== null) {
events.push(
[this._mouseButton, 'mousedown', this._onMouseButtonMouseDown.bind(this), false],
+ [this._mouseButton, 'pointerdown', this._onMouseButtonPointerDown.bind(this), false],
[this._mouseButton, 'mouseup', this._onMouseButtonMouseUp.bind(this), false],
[this._mouseButton, 'contextmenu', this._onMouseButtonContextMenu.bind(this), false]
);
@@ -175,6 +177,19 @@ class KeyboardMouseInputField extends EventDispatcher {
this._addInputs(DocumentUtil.getActiveButtons(e));
}
+ _onMouseButtonPointerDown(e) {
+ const {isPrimary, pointerType} = e;
+ if (
+ !isPrimary ||
+ typeof this._isPointerTypeSupported !== 'function' ||
+ !this._isPointerTypeSupported(pointerType)
+ ) {
+ return;
+ }
+ e.preventDefault();
+ this._addInputs(DocumentUtil.getActiveButtons(e));
+ }
+
_onMouseButtonMouseUp(e) {
e.preventDefault();
}