mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-04 08:50:33 +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
68 lines
1.8 KiB
JavaScript
Executable File
68 lines
1.8 KiB
JavaScript
Executable File
import IPointing from "./IPointing.js"
|
|
|
|
/**
|
|
* @typedef {import("./IPointing.js").Options & {
|
|
* consumeEvent?: Boolean,
|
|
* strictTarget?: Boolean,
|
|
* }} Options
|
|
*/
|
|
|
|
/**
|
|
* @template {HTMLElement} T
|
|
* @extends {IPointing<T>}
|
|
*/
|
|
export default class MouseDbClick extends IPointing {
|
|
|
|
/** @param {Coordinates} location */
|
|
static ignoreDbClick = location => { }
|
|
|
|
/** @param {MouseEvent} e */
|
|
#mouseDbClickHandler = e => {
|
|
if (!this.options.strictTarget || e.target === e.currentTarget) {
|
|
if (this.consumeEvent) {
|
|
e.stopImmediatePropagation() // Captured, don't call anyone else
|
|
}
|
|
this.clickedPosition = this.setLocationFromEvent(e)
|
|
this.blueprint.mousePosition = [...this.clickedPosition]
|
|
this.dbclicked(this.clickedPosition)
|
|
}
|
|
}
|
|
|
|
#onDbClick
|
|
get onDbClick() {
|
|
return this.#onDbClick
|
|
}
|
|
set onDbClick(value) {
|
|
this.#onDbClick = value
|
|
}
|
|
|
|
clickedPosition = /** @type {Coordinates} */([0, 0])
|
|
|
|
/**
|
|
* @param {T} target
|
|
* @param {Blueprint} blueprint
|
|
* @param {Options} options
|
|
*/
|
|
constructor(target, blueprint, options = {}, onDbClick = MouseDbClick.ignoreDbClick) {
|
|
options.consumeEvent ??= true
|
|
options.strictTarget ??= false
|
|
super(target, blueprint, options)
|
|
this.#onDbClick = onDbClick
|
|
this.listenEvents()
|
|
}
|
|
|
|
listenEvents() {
|
|
this.target.addEventListener("dblclick", this.#mouseDbClickHandler)
|
|
}
|
|
|
|
unlistenEvents() {
|
|
this.target.removeEventListener("dblclick", this.#mouseDbClickHandler)
|
|
}
|
|
|
|
/* Subclasses will override the following method */
|
|
/** @param {Coordinates} location */
|
|
dbclicked(location) {
|
|
this.onDbClick(location)
|
|
}
|
|
}
|