Fixed issue in preventMouseDownDefault

This commit is contained in:
Francisco Hodge 2019-09-26 11:13:43 -04:00
parent 0872203d9e
commit a3240e4315

View File

@ -307,6 +307,16 @@ class SimpleKeyboard {
this.options.onKeyReleased(button); this.options.onKeyReleased(button);
} }
/**
* Handles container mousedown
*/
handleKeyboardContainerMouseDown(e) {
/**
* Handle event options
*/
if (this.options.preventMouseDownDefault) e.preventDefault();
}
/** /**
* Handles button hold * Handles button hold
*/ */
@ -1271,7 +1281,7 @@ class SimpleKeyboard {
this.initialized = true; this.initialized = true;
/** /**
* Handling onpointerup * Handling parent events
*/ */
/* istanbul ignore next */ /* istanbul ignore next */
if ( if (
@ -1280,17 +1290,24 @@ class SimpleKeyboard {
!useMouseEvents !useMouseEvents
) { ) {
document.onpointerup = () => this.handleButtonMouseUp(); document.onpointerup = () => this.handleButtonMouseUp();
this.keyboardDOM.onpointerdown = e =>
this.handleKeyboardContainerMouseDown(e);
} else if (useTouchEvents) { } else if (useTouchEvents) {
/** /**
* Handling ontouchend, ontouchcancel * Handling ontouchend, ontouchcancel
*/ */
document.ontouchend = () => this.handleButtonMouseUp(); document.ontouchend = () => this.handleButtonMouseUp();
document.ontouchcancel = () => this.handleButtonMouseUp(); document.ontouchcancel = () => this.handleButtonMouseUp();
this.keyboardDOM.ontouchstart = e =>
this.handleKeyboardContainerMouseDown(e);
} else if (!useTouchEvents) { } else if (!useTouchEvents) {
/** /**
* Handling mouseup * Handling mouseup
*/ */
document.onmouseup = () => this.handleButtonMouseUp(); document.onmouseup = () => this.handleButtonMouseUp();
this.keyboardDOM.onmousedown = e =>
this.handleKeyboardContainerMouseDown(e);
} }
/** /**