mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-02-22 01:29:39 +08:00
Add enableLayoutCandidatesKeyPress option. Fixes #1866
This commit is contained in:
parent
a198d02259
commit
b2872b7809
@ -135,6 +135,7 @@ class SimpleKeyboard {
|
|||||||
* @property {number} layoutCandidatesPageSize Determines size of layout candidate list
|
* @property {number} layoutCandidatesPageSize Determines size of layout candidate list
|
||||||
* @property {boolean} layoutCandidatesCaseSensitiveMatch Determines whether layout candidate match should be case sensitive.
|
* @property {boolean} layoutCandidatesCaseSensitiveMatch Determines whether layout candidate match should be case sensitive.
|
||||||
* @property {boolean} disableCandidateNormalization Disables the automatic normalization for selected layout candidates
|
* @property {boolean} disableCandidateNormalization Disables the automatic normalization for selected layout candidates
|
||||||
|
* @property {boolean} enableLayoutCandidatesKeyPress Enables onKeyPress triggering for layoutCandidate items
|
||||||
*/
|
*/
|
||||||
this.options = {
|
this.options = {
|
||||||
layoutName: "default",
|
layoutName: "default",
|
||||||
@ -377,7 +378,11 @@ class SimpleKeyboard {
|
|||||||
candidateValue,
|
candidateValue,
|
||||||
targetElement,
|
targetElement,
|
||||||
onSelect: (selectedCandidate: string, e: MouseEvent) => {
|
onSelect: (selectedCandidate: string, e: MouseEvent) => {
|
||||||
const { layoutCandidatesCaseSensitiveMatch, disableCandidateNormalization } = this.options;
|
const {
|
||||||
|
layoutCandidatesCaseSensitiveMatch,
|
||||||
|
disableCandidateNormalization,
|
||||||
|
enableLayoutCandidatesKeyPress
|
||||||
|
} = this.options;
|
||||||
|
|
||||||
let candidateStr = selectedCandidate;
|
let candidateStr = selectedCandidate;
|
||||||
|
|
||||||
@ -413,6 +418,14 @@ class SimpleKeyboard {
|
|||||||
this.setInput(newInput, this.options.inputName, true);
|
this.setInput(newInput, this.options.inputName, true);
|
||||||
this.setCaretPosition(newCaretPosition);
|
this.setCaretPosition(newCaretPosition);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calling onKeyPress
|
||||||
|
* We pass in the composed candidate instead of the decomposed one
|
||||||
|
* To prevent confusion for users
|
||||||
|
*/
|
||||||
|
if (enableLayoutCandidatesKeyPress && typeof this.options.onKeyPress === "function")
|
||||||
|
this.options.onKeyPress(selectedCandidate, e);
|
||||||
|
|
||||||
if (typeof this.options.onChange === "function")
|
if (typeof this.options.onChange === "function")
|
||||||
this.options.onChange(
|
this.options.onChange(
|
||||||
this.getInput(this.options.inputName, true),
|
this.getInput(this.options.inputName, true),
|
||||||
|
@ -256,6 +256,11 @@ export interface KeyboardOptions {
|
|||||||
*/
|
*/
|
||||||
disableCandidateNormalization?: boolean;
|
disableCandidateNormalization?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables onKeyPress triggering for layoutCandidate items
|
||||||
|
*/
|
||||||
|
enableLayoutCandidatesKeyPress?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).
|
* Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user