Input system cleanup

This commit is contained in:
barsdeveloper
2022-11-10 22:43:47 +01:00
parent 101071f137
commit 18bf858db3
16 changed files with 183 additions and 170 deletions

View File

@@ -1,13 +0,0 @@
import IFocus from "./IFocus"
export default class FocusTextEdit extends IFocus {
focused() {
this.blueprint.dispatchEditTextEvent(true)
}
unfocused() {
document.getSelection()?.removeAllRanges() // Deselect eventually selected text inside the input
this.blueprint.dispatchEditTextEvent(false)
}
}

View File

@@ -1,40 +0,0 @@
import IInput from "../IInput"
export default class IFocus extends IInput {
/** @type {(e: FocusEvent) => void} */
#focusHandler
/** @type {(e: FocusEvent) => void} */
#focusoutHandler
constructor(target, blueprint, options = {}) {
options.listenOnFocus ??= true
super(target, blueprint, options)
const self = this
this.#focusHandler = e => {
e.preventDefault()
this.focused()
}
this.#focusoutHandler = e => {
e.preventDefault()
this.unfocused()
}
}
listenEvents() {
this.target.addEventListener("focus", this.#focusHandler)
this.target.addEventListener("focusout", this.#focusoutHandler)
}
unlistenEvents() {
this.target.removeEventListener("focus", this.#focusHandler)
this.target.removeEventListener("focusout", this.#focusoutHandler)
}
focused() {
}
unfocused() {
}
}