mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-01-19 16:52:59 +08:00
Added autoUseTouchEvents and related touch device fixes
This commit is contained in:
parent
30042d5d72
commit
ed944d1204
@ -66,7 +66,7 @@ html {
|
|||||||
font-size: inherit;
|
font-size: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
.simple-keyboard.hg-theme-default .hg-button:active {
|
.simple-keyboard.hg-theme-default:not(.hg-touch-events) .hg-button:active {
|
||||||
background: #e4e4e4;
|
background: #e4e4e4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +61,8 @@ class SimpleKeyboard {
|
|||||||
* @property {boolean} useButtonTag Render buttons as a button element instead of a div element.
|
* @property {boolean} useButtonTag Render buttons as a button element instead of a div element.
|
||||||
* @property {boolean} disableCaretPositioning A prop to ensure characters are always be added/removed at the end of the string.
|
* @property {boolean} disableCaretPositioning A prop to ensure characters are always be added/removed at the end of the string.
|
||||||
* @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} autoUseTouchEvents Enable useTouchEvents automatically when touch device is detected.
|
||||||
*/
|
*/
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.options.layoutName = this.options.layoutName || "default";
|
this.options.layoutName = this.options.layoutName || "default";
|
||||||
@ -618,6 +620,20 @@ class SimpleKeyboard {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process autoTouchEvents option
|
||||||
|
*/
|
||||||
|
processAutoTouchEvents(){
|
||||||
|
if (this.options.autoUseTouchEvents){
|
||||||
|
this.options.useTouchEvents = true;
|
||||||
|
|
||||||
|
if (this.options.debug) {
|
||||||
|
console.log(`autoUseTouchEvents: Touch device detected, useTouchEvents enabled.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the callback function once simple-keyboard is rendered for the first time (on initialization).
|
* Executes the callback function once simple-keyboard is rendered for the first time (on initialization).
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user