mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-05-20 04:47:35 +08:00
WIP
This commit is contained in:
@@ -14,38 +14,33 @@ export default class IContext {
|
||||
/** @type {Object} */
|
||||
options
|
||||
|
||||
#hasFocus = false
|
||||
|
||||
get hasFocus() {
|
||||
return this.#hasFocus
|
||||
}
|
||||
|
||||
set hasFocus(_) {
|
||||
}
|
||||
|
||||
constructor(target, blueprint, options) {
|
||||
this.target = target
|
||||
this.blueprint = blueprint
|
||||
this.options = options
|
||||
let self = this
|
||||
this.blueprintFocusHandler = _ => {
|
||||
this.#hasFocus = true
|
||||
this.listenHandler = _ => {
|
||||
self.listenEvents()
|
||||
}
|
||||
this.blueprintUnfocusHandler = _ => {
|
||||
this.unlistenHandler = _ => {
|
||||
self.unlistenEvents()
|
||||
this.#hasFocus = false
|
||||
}
|
||||
if (options?.wantsFocusCallback ?? false) {
|
||||
this.blueprint.addEventListener("blueprint-focus", this.blueprintFocusHandler)
|
||||
this.blueprint.addEventListener("blueprint-unfocus", this.blueprintUnfocusHandler)
|
||||
if (options?.listenOnFocus ?? false) {
|
||||
this.blueprint.addEventListener("blueprint-focus", this.listenHandler)
|
||||
this.blueprint.addEventListener("blueprint-unfocus", this.unlistenHandler)
|
||||
}
|
||||
if (options?.unlistenOnEditText ?? false) {
|
||||
this.blueprint.addEventListener(this.blueprint.settings.editTextEventName.begin, this.unlistenHandler)
|
||||
this.blueprint.addEventListener(this.blueprint.settings.editTextEventName.end, this.listenHandler)
|
||||
}
|
||||
}
|
||||
|
||||
unlistenDOMElement() {
|
||||
this.unlistenEvents()
|
||||
this.blueprint.removeEventListener("blueprint-focus", this.blueprintFocusHandler)
|
||||
this.blueprint.removeEventListener("blueprint-unfocus", this.blueprintUnfocusHandler)
|
||||
this.blueprint.removeEventListener("blueprint-focus", this.listenHandler)
|
||||
this.blueprint.removeEventListener("blueprint-unfocus", this.unlistenHandler)
|
||||
this.blueprint.removeEventListener(this.blueprint.settings.editTextEventName.begin, this.unlistenHandler)
|
||||
this.blueprint.removeEventListener(this.blueprint.settings.editTextEventName.end, this.listenHandler)
|
||||
}
|
||||
|
||||
/* Subclasses will probabily override the following methods */
|
||||
|
||||
Reference in New Issue
Block a user