This commit is contained in:
barsdeveloper
2022-04-02 11:13:34 +02:00
parent 9ab8801eee
commit e901932953
26 changed files with 392 additions and 279 deletions

View File

@@ -10,7 +10,7 @@ export default class IKeyboardShortcut extends IContext {
#activationKeys
constructor(target, blueprint, options = {}) {
options.wantsFocusCallback = true
options.listenOnFocus = true
options.activationKeys ??= []
if (!(options.activationKeys instanceof Array)) {
options.activationKeys = [options.activationKeys]
@@ -47,6 +47,9 @@ export default class IKeyboardShortcut extends IContext {
&& wantsAlt(keyEntry) == e.altKey
&& this.blueprint.settings.Keys[keyEntry.Key] == e.code
)) {
if (options.consumeEvent) {
e.stopImmediatePropagation()
}
self.fire()
document.removeEventListener("keydown", self.keyDownHandler)
document.addEventListener("keyup", self.keyUpHandler)
@@ -60,9 +63,12 @@ export default class IKeyboardShortcut extends IContext {
keyEntry.bShift && e.key == "Shift"
|| keyEntry.bCtrl && e.key == "Control"
|| keyEntry.bAlt && e.key == "Alt"
|| keyEntry.bCmd && e.key == "Meta" // Unsure about this, what key is that?
|| keyEntry.bCmd && e.key == "Meta"
|| this.blueprint.settings.Keys[keyEntry.Key] == e.code
)) {
if (options.consumeEvent) {
e.stopImmediatePropagation()
}
self.unfire()
document.removeEventListener("keyup", this.keyUpHandler)
document.addEventListener("keydown", this.keyDownHandler)

View File

@@ -5,7 +5,7 @@ import Zoom from "../mouse/Zoom"
export default class KeyboardEnableZoom extends IKeyboardShortcut {
/** @type {} */
/** @type {Zoom} */
#zoomInputObject
/**

View File

@@ -0,0 +1,26 @@
// @ts-check
import KeyboardSelectAll from "./KeyboardSelectAll"
export default class KeyboardIgnoreSelectAll extends KeyboardSelectAll {
/**
* @param {HTMLElement} target
* @param {any} blueprint
* @param {Object} options
*/
constructor(target, blueprint, options = {}) {
options = {
...options,
activationKeys: blueprint.settings.selectAllKeyboardKey
}
super(target, blueprint, options)
}
fire() {
}
unfire() {
}
}

View File

@@ -2,11 +2,14 @@
import IKeyboardShortcut from "./IKeyboardShortcut"
/**
* @typedef {import("../../Blueprint").default} Blueprint
*/
export default class KeyboardSelectAll extends IKeyboardShortcut {
/**
* @param {HTMLElement} target
* @param {import("../../Blueprint").default} blueprint
* @param {Blueprint} blueprint
* @param {Object} options
*/
constructor(target, blueprint, options = {}) {