Files
ueblueprint/js/input/Context.js
2021-12-06 22:07:51 +01:00

31 lines
1.0 KiB
JavaScript

export default class Context {
constructor(target, blueprint, options) {
/** @type {HTMLElement} */
this.target = target
/** @type {import("../Blueprint").default}" */
this.blueprint = blueprint
this.options = options
if (options?.wantsFocusCallback ?? false) {
let self = this
this.blueprintfocusHandler = _ => self.blueprintFocused()
this.blueprintunfocusHandler = _ => self.blueprintUnfocused()
this.blueprint.addEventListener("blueprintfocus", this.blueprintfocusHandler)
this.blueprint.addEventListener("blueprintunfocus", this.blueprintunfocusHandler)
}
}
unlistenDOMElement() {
this.blueprint.removeEventListener("blueprintfocus", this.blueprintfocusHandler)
this.blueprint.removeEventListener("blueprintunfocus", this.blueprintunfocusHandler)
}
/* Subclasses will probabily override the following methods */
blueprintFocused() {
}
blueprintUnfocused() {
}
}