mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-02-22 01:29:39 +08:00
Handle selectionchange event. Fixes #1140
This commit is contained in:
parent
f20221eae2
commit
7e256907b8
File diff suppressed because one or more lines are too long
4
build/types/components/Keyboard.d.ts
vendored
4
build/types/components/Keyboard.d.ts
vendored
@ -198,6 +198,10 @@ declare class SimpleKeyboard {
|
|||||||
* Event Handler: Select
|
* Event Handler: Select
|
||||||
*/
|
*/
|
||||||
handleSelect(event: KeyboardHandlerEvent): void;
|
handleSelect(event: KeyboardHandlerEvent): void;
|
||||||
|
/**
|
||||||
|
* Event Handler: SelectionChange
|
||||||
|
*/
|
||||||
|
handleSelectionChange(event: KeyboardHandlerEvent): void;
|
||||||
/**
|
/**
|
||||||
* Called by {@link setEventListeners} when an event that warrants a cursor position update is triggered
|
* Called by {@link setEventListeners} when an event that warrants a cursor position update is triggered
|
||||||
*/
|
*/
|
||||||
|
@ -1048,6 +1048,7 @@ class SimpleKeyboard {
|
|||||||
document.addEventListener("mouseup", this.handleMouseUp);
|
document.addEventListener("mouseup", this.handleMouseUp);
|
||||||
document.addEventListener("touchend", this.handleTouchEnd);
|
document.addEventListener("touchend", this.handleTouchEnd);
|
||||||
document.addEventListener("select", this.handleSelect);
|
document.addEventListener("select", this.handleSelect);
|
||||||
|
document.addEventListener("selectionchange", this.handleSelectionChange);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1094,6 +1095,14 @@ class SimpleKeyboard {
|
|||||||
this.caretEventHandler(event);
|
this.caretEventHandler(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event Handler: SelectionChange
|
||||||
|
*/
|
||||||
|
/* istanbul ignore next */
|
||||||
|
handleSelectionChange(event: KeyboardHandlerEvent): void {
|
||||||
|
this.caretEventHandler(event);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by {@link setEventListeners} when an event that warrants a cursor position update is triggered
|
* Called by {@link setEventListeners} when an event that warrants a cursor position update is triggered
|
||||||
*/
|
*/
|
||||||
@ -1143,7 +1152,10 @@ class SimpleKeyboard {
|
|||||||
`(${instance.keyboardDOMClass})`
|
`(${instance.keyboardDOMClass})`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (instance.options.disableCaretPositioning || !isKeyboard) {
|
} else if (
|
||||||
|
(instance.options.disableCaretPositioning || !isKeyboard) &&
|
||||||
|
event?.type !== "selectionchange"
|
||||||
|
) {
|
||||||
/**
|
/**
|
||||||
* If we toggled off disableCaretPositioning, we must ensure caretPosition doesn't persist once reactivated.
|
* If we toggled off disableCaretPositioning, we must ensure caretPosition doesn't persist once reactivated.
|
||||||
*/
|
*/
|
||||||
@ -1192,6 +1204,7 @@ class SimpleKeyboard {
|
|||||||
document.removeEventListener("mouseup", this.handleMouseUp);
|
document.removeEventListener("mouseup", this.handleMouseUp);
|
||||||
document.removeEventListener("touchend", this.handleTouchEnd);
|
document.removeEventListener("touchend", this.handleTouchEnd);
|
||||||
document.removeEventListener("select", this.handleSelect);
|
document.removeEventListener("select", this.handleSelect);
|
||||||
|
document.removeEventListener("selectionchange", this.handleSelectionChange);
|
||||||
document.onpointerup = null;
|
document.onpointerup = null;
|
||||||
document.ontouchend = null;
|
document.ontouchend = null;
|
||||||
document.ontouchcancel = null;
|
document.ontouchcancel = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user