mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-04-29 01:00:13 +08:00
useMouseEvents: Fire click handler in mousedown. Fixes #1621
This commit is contained in:
parent
67efd3701a
commit
fab0dacf03
@ -1861,9 +1861,22 @@ class SimpleKeyboard {
|
|||||||
*/
|
*/
|
||||||
buttonDOM.onclick = (e: KeyboardHandlerEvent) => {
|
buttonDOM.onclick = (e: KeyboardHandlerEvent) => {
|
||||||
this.setMouseHold(false);
|
this.setMouseHold(false);
|
||||||
this.handleButtonClicked(button, e);
|
/**
|
||||||
|
* Fire button handler in onclick for compatibility reasons
|
||||||
|
* This fires handler before onKeyReleased, therefore when that option is set we will fire the handler
|
||||||
|
* in onmousedown instead
|
||||||
|
*/
|
||||||
|
if(typeof this.options.onKeyReleased !== "function"){
|
||||||
|
this.handleButtonClicked(button, e);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
buttonDOM.onmousedown = (e: KeyboardHandlerEvent) => {
|
buttonDOM.onmousedown = (e: KeyboardHandlerEvent) => {
|
||||||
|
/**
|
||||||
|
* Fire button handler for onKeyReleased use-case
|
||||||
|
*/
|
||||||
|
if(typeof this.options.onKeyReleased === "function" && !this.isMouseHold){
|
||||||
|
this.handleButtonClicked(button, e);
|
||||||
|
}
|
||||||
this.handleButtonMouseDown(button, e);
|
this.handleButtonMouseDown(button, e);
|
||||||
};
|
};
|
||||||
buttonDOM.onmouseup = (e: KeyboardHandlerEvent) => {
|
buttonDOM.onmouseup = (e: KeyboardHandlerEvent) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user