mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-04 16:54:41 +08:00
* Fix node reference when changing elements * Fix ScriptVariables parsing * Fix invariant text and niagara types * Niagara convert nodes * Move node tests to own files * More Niagara tests * Niagara float and smaller fixes * More Decoding * More decoding * WIP * Float is real * WIP * More types and colors * Test case and small polish * WIP * WIP * Fix niagara script variables merging * Fix Niagara variables * Fixing mirrored ExportPath * Fix Export paths name adjustments * Simplify arc calculation * Simplify a bit arc calculation * source / destionation => origin / target * Minor refactoring * Fix switched link position * Rename some properties for uniformity * Fix input escape * Simplify test * About window * Dialog backdrop style * About dialog touches * Remove dependency and minot improvement * Light mode * Fix link location and css small improvement * Link direction and minor fixes * Some minor fixes and refactoring * Refactoring WIP * Shorting repetitive bits * More tests * Simplify linking tests
79 lines
2.2 KiB
JavaScript
Executable File
79 lines
2.2 KiB
JavaScript
Executable File
import Configuration from "../Configuration.js"
|
|
|
|
/**
|
|
* @typedef {{
|
|
* consumeEvent?: Boolean,
|
|
* listenOnFocus?: Boolean,
|
|
* unlistenOnTextEdit?: Boolean,
|
|
* }} Options
|
|
*/
|
|
|
|
/** @template {Element} T */
|
|
export default class IInput {
|
|
|
|
/** @type {T} */
|
|
#target
|
|
get target() {
|
|
return this.#target
|
|
}
|
|
|
|
/** @type {Blueprint} */
|
|
#blueprint
|
|
get blueprint() {
|
|
return this.#blueprint
|
|
}
|
|
|
|
consumeEvent
|
|
|
|
/** @type {Object} */
|
|
options
|
|
|
|
|
|
listenHandler = () => this.listenEvents()
|
|
unlistenHandler = () => this.unlistenEvents()
|
|
|
|
/**
|
|
* @param {T} target
|
|
* @param {Blueprint} blueprint
|
|
* @param {Options} options
|
|
*/
|
|
constructor(target, blueprint, options = {}) {
|
|
options.consumeEvent ??= false
|
|
options.listenOnFocus ??= false
|
|
options.unlistenOnTextEdit ??= false
|
|
this.#target = target
|
|
this.#blueprint = blueprint
|
|
this.consumeEvent = options.consumeEvent
|
|
this.options = options
|
|
}
|
|
|
|
setup() {
|
|
if (this.options.listenOnFocus) {
|
|
this.blueprint.addEventListener(Configuration.focusEventName.begin, this.listenHandler)
|
|
this.blueprint.addEventListener(Configuration.focusEventName.end, this.unlistenHandler)
|
|
}
|
|
if (this.options.unlistenOnTextEdit) {
|
|
this.blueprint.addEventListener(Configuration.editTextEventName.begin, this.unlistenHandler)
|
|
this.blueprint.addEventListener(Configuration.editTextEventName.end, this.listenHandler)
|
|
}
|
|
if (this.blueprint.focused) {
|
|
this.listenEvents()
|
|
}
|
|
}
|
|
|
|
cleanup() {
|
|
this.unlistenEvents()
|
|
this.blueprint.removeEventListener(Configuration.focusEventName.begin, this.listenHandler)
|
|
this.blueprint.removeEventListener(Configuration.focusEventName.end, this.unlistenHandler)
|
|
this.blueprint.removeEventListener(Configuration.editTextEventName.begin, this.unlistenHandler)
|
|
this.blueprint.removeEventListener(Configuration.editTextEventName.end, this.listenHandler)
|
|
}
|
|
|
|
/* Subclasses will probabily override the following methods */
|
|
listenEvents() {
|
|
}
|
|
|
|
unlistenEvents() {
|
|
}
|
|
}
|