mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-01-19 16:52:59 +08:00
Adding useMouseEvents option
This commit is contained in:
parent
48a15e6715
commit
30941f4ba0
5
src/lib/@types/index.d.ts
vendored
5
src/lib/@types/index.d.ts
vendored
@ -121,6 +121,11 @@ declare module 'simple-keyboard' {
|
|||||||
*/
|
*/
|
||||||
autoUseTouchEvents?: boolean;
|
autoUseTouchEvents?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opt out of PointerEvents handling, falling back to the prior mouse event logic.
|
||||||
|
*/
|
||||||
|
useMouseEvents?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the callback function on key press. Returns button layout name (i.e.: "{shift}").
|
* Executes the callback function on key press. Returns button layout name (i.e.: "{shift}").
|
||||||
*/
|
*/
|
||||||
|
@ -63,6 +63,7 @@ class SimpleKeyboard {
|
|||||||
* @property {object} inputPattern Restrains input(s) change to the defined regular expression pattern.
|
* @property {object} inputPattern Restrains input(s) change to the defined regular expression pattern.
|
||||||
* @property {boolean} useTouchEvents Instructs simple-keyboard to use touch events instead of click events.
|
* @property {boolean} useTouchEvents Instructs simple-keyboard to use touch events instead of click events.
|
||||||
* @property {boolean} autoUseTouchEvents Enable useTouchEvents automatically when touch device is detected.
|
* @property {boolean} autoUseTouchEvents Enable useTouchEvents automatically when touch device is detected.
|
||||||
|
* @property {boolean} useMouseEvents Opt out of PointerEvents handling, falling back to the prior mouse event logic.
|
||||||
*/
|
*/
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.options.layoutName = this.options.layoutName || "default";
|
this.options.layoutName = this.options.layoutName || "default";
|
||||||
@ -843,6 +844,7 @@ class SimpleKeyboard {
|
|||||||
let layout = this.options.layout || KeyboardLayout.getDefaultLayout();
|
let layout = this.options.layout || KeyboardLayout.getDefaultLayout();
|
||||||
let useTouchEvents = this.options.useTouchEvents || false;
|
let useTouchEvents = this.options.useTouchEvents || false;
|
||||||
let useTouchEventsClass = useTouchEvents ? "hg-touch-events" : "";
|
let useTouchEventsClass = useTouchEvents ? "hg-touch-events" : "";
|
||||||
|
let useMouseEvents = this.options.useMouseEvents || false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Account for buttonTheme, if set
|
* Account for buttonTheme, if set
|
||||||
@ -895,7 +897,11 @@ class SimpleKeyboard {
|
|||||||
* Handle button click event
|
* Handle button click event
|
||||||
*/
|
*/
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
if (this.utilities.pointerEventsSupported() && !useTouchEvents) {
|
if (
|
||||||
|
this.utilities.pointerEventsSupported() &&
|
||||||
|
!useTouchEvents &&
|
||||||
|
!useMouseEvents
|
||||||
|
) {
|
||||||
/**
|
/**
|
||||||
* PointerEvents support
|
* PointerEvents support
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user