mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-05-21 05:27:34 +08:00
Various improvements
This commit is contained in:
41
js/input/keybaord/KeyboardShortcutAction.js
Normal file
41
js/input/keybaord/KeyboardShortcutAction.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import IKeyboardShortcut from "./IKeyboardShortcut"
|
||||
|
||||
/** @typedef {import("../../Blueprint").default} Blueprint */
|
||||
|
||||
/**
|
||||
* @template {HTMLElement} T
|
||||
* @extends IKeyboardShortcut<T>
|
||||
*/
|
||||
export default class KeyboardShortcutAction extends IKeyboardShortcut {
|
||||
|
||||
static #ignoreEvent =
|
||||
/** @param {KeyboardShortcutAction} self */
|
||||
self => { }
|
||||
|
||||
/**
|
||||
* @param {T} target
|
||||
* @param {Blueprint} blueprint
|
||||
* @param {Object} options
|
||||
* @param {(self: KeyboardShortcutAction<T>) => void} onKeyDown
|
||||
* @param {(self: KeyboardShortcutAction<T>) => void} onKeyUp
|
||||
*/
|
||||
constructor(
|
||||
target,
|
||||
blueprint,
|
||||
options,
|
||||
onKeyDown = KeyboardShortcutAction.#ignoreEvent,
|
||||
onKeyUp = KeyboardShortcutAction.#ignoreEvent
|
||||
) {
|
||||
super(target, blueprint, options)
|
||||
this.onKeyDown = onKeyDown
|
||||
this.onKeyUp = onKeyUp
|
||||
}
|
||||
|
||||
fire() {
|
||||
this.onKeyDown(this)
|
||||
}
|
||||
|
||||
unfire() {
|
||||
this.onKeyUp(this)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user