Text edit input behavior fixed

This commit is contained in:
barsdeveloper
2022-04-18 22:38:50 +02:00
parent d43ae1b11f
commit 2ebd55b31d
15 changed files with 141 additions and 71 deletions

View File

@@ -11,8 +11,10 @@ export default class IKeyboardShortcut extends IInput {
#activationKeys
constructor(target, blueprint, options = {}) {
options.listenOnFocus = true
options.activateAnyKey ??= false
options.activationKeys ??= []
options.listenOnFocus ??= true
options.unlistenOnTextEdit ??= true
if (!(options.activationKeys instanceof Array)) {
options.activationKeys = [options.activationKeys]
}
@@ -42,12 +44,14 @@ export default class IKeyboardShortcut extends IInput {
/** @param {KeyboardEvent} e */
this.keyDownHandler = e => {
if (
self.#activationKeys.some(keyEntry =>
this.options.activateAnyKey
|| self.#activationKeys.some(keyEntry =>
wantsShift(keyEntry) == e.shiftKey
&& wantsCtrl(keyEntry) == e.ctrlKey
&& wantsAlt(keyEntry) == e.altKey
&& Configuration.Keys[keyEntry.Key] == e.code
)) {
)
) {
if (options.consumeEvent) {
e.stopImmediatePropagation()
}
@@ -60,13 +64,15 @@ export default class IKeyboardShortcut extends IInput {
/** @param {KeyboardEvent} e */
this.keyUpHandler = e => {
if (
self.#activationKeys.some(keyEntry =>
this.options.activateAnyKey
|| self.#activationKeys.some(keyEntry =>
keyEntry.bShift && e.key == "Shift"
|| keyEntry.bCtrl && e.key == "Control"
|| keyEntry.bAlt && e.key == "Alt"
|| keyEntry.bCmd && e.key == "Meta"
|| Configuration.Keys[keyEntry.Key] == e.code
)) {
)
) {
if (options.consumeEvent) {
e.stopImmediatePropagation()
}

View File

@@ -11,10 +11,7 @@ export default class KeyboardCanc extends IKeyboardShortcut {
* @param {Object} options
*/
constructor(target, blueprint, options = {}) {
options = {
...options,
activationKeys: Configuration.deleteNodesKeyboardKey
}
options.activationKeys = Configuration.deleteNodesKeyboardKey
super(target, blueprint, options)
}

View File

@@ -15,10 +15,7 @@ export default class KeyboardEnableZoom extends IKeyboardShortcut {
* @param {Object} options
*/
constructor(target, blueprint, options = {}) {
options = {
...options,
activationKeys: Configuration.enableZoomIn
}
options.activationKeys = Configuration.enableZoomIn
super(target, blueprint, options)
}

View File

@@ -14,10 +14,7 @@ export default class KeyboardSelectAll extends IKeyboardShortcut {
* @param {Object} options
*/
constructor(target, blueprint, options = {}) {
options = {
...options,
activationKeys: Configuration.selectAllKeyboardKey
}
options.activationKeys = Configuration.selectAllKeyboardKey
super(target, blueprint, options)
}