mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-01-19 16:52:59 +08:00
caretPosition reset when inputName is changed through setOptions
This commit is contained in:
parent
451b64d31a
commit
20d24d97fd
@ -363,14 +363,40 @@ class SimpleKeyboard {
|
||||
|
||||
/**
|
||||
* Set new option or modify existing ones after initialization.
|
||||
* @param {object} option The option to set
|
||||
* @param {object} options The options to set
|
||||
*/
|
||||
setOptions = option => {
|
||||
option = option || {};
|
||||
this.options = Object.assign(this.options, option);
|
||||
setOptions(options){
|
||||
options = options || {};
|
||||
this.options = Object.assign(this.options, options);
|
||||
|
||||
/**
|
||||
* Some option changes require adjustments before re-render
|
||||
*/
|
||||
this.onSetOptions(options);
|
||||
|
||||
/**
|
||||
* Rendering
|
||||
*/
|
||||
this.render();
|
||||
};
|
||||
|
||||
/**
|
||||
* Executing actions depending on changed options
|
||||
* @param {object} options The options to set
|
||||
*/
|
||||
onSetOptions(options){
|
||||
if(options.inputName){
|
||||
/**
|
||||
* inputName changed. This requires a caretPosition reset
|
||||
*/
|
||||
if (this.options.debug) {
|
||||
console.log("inputName changed. caretPosition reset.");
|
||||
}
|
||||
|
||||
this.caretPosition = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all keyboard rows and reset keyboard values.
|
||||
* Used interally between re-renders.
|
||||
|
Loading…
Reference in New Issue
Block a user