${this.renderWindowName()}
-
+
this.element.remove()}">
`
}
@@ -4528,9 +4582,7 @@ class IInputPinTemplate extends PinTemplate {
getInputs() {
return this.#inputContentElements.map(element =>
// Faster than innerText which causes reflow
- element.innerHTML
- .replaceAll(" ", "\u00A0")
- .replaceAll("
", "\n")
+ Utility.clearHTMLWhitespace(element.innerHTML)
)
}
@@ -4562,6 +4614,112 @@ class IInputPinTemplate extends PinTemplate {
}
}
+/** @typedef {import("../../Blueprint").default} Blueprint */
+
+/**
+ * @template {HTMLElement} T
+ * @extends {IPointing
}
+ */
+class IMouseClick extends IPointing {
+
+ /** @type {(e: MouseEvent) => void} */
+ #mouseDownHandler
+
+ /** @type {(e: MouseEvent) => void} */
+ #mouseUpHandler
+
+ constructor(target, blueprint, options = {}) {
+ options.clickButton ??= 0;
+ options.consumeEvent ??= true;
+ options.exitAnyButton ??= true;
+ options.strictTarget ??= false;
+ super(target, blueprint, options);
+ this.clickedPosition = [0, 0];
+ let self = this;
+
+ this.#mouseDownHandler = e => {
+ self.blueprint.setFocused(true);
+ switch (e.button) {
+ case self.options.clickButton:
+ // Either doesn't matter or consider the click only when clicking on the target, not descandants
+ if (!self.options.strictTarget || e.target == e.currentTarget) {
+ if (self.options.consumeEvent) {
+ e.stopImmediatePropagation(); // Captured, don't call anyone else
+ }
+ // Attach the listeners
+ document.addEventListener("mouseup", self.#mouseUpHandler);
+ self.clickedPosition = self.locationFromEvent(e);
+ self.clicked(self.clickedPosition);
+ }
+ break
+ default:
+ if (!self.options.exitAnyButton) {
+ self.#mouseUpHandler(e);
+ }
+ break
+ }
+ };
+
+ this.#mouseUpHandler = e => {
+ if (!self.options.exitAnyButton || e.button == self.options.clickButton) {
+ if (self.options.consumeEvent) {
+ e.stopImmediatePropagation(); // Captured, don't call anyone else
+ }
+ // Remove the handlers of "mousemove" and "mouseup"
+ document.removeEventListener("mouseup", self.#mouseUpHandler);
+ self.unclicked();
+ }
+ };
+
+ this.listenEvents();
+ }
+
+ listenEvents() {
+ this.target.addEventListener("mousedown", this.#mouseDownHandler);
+ if (this.options.clickButton == 2) {
+ this.target.addEventListener("contextmenu", e => e.preventDefault());
+ }
+ }
+
+ unlistenEvents() {
+ this.target.removeEventListener("mousedown", this.#mouseDownHandler);
+ }
+
+ /* Subclasses will override the following methods */
+ clicked(location) {
+ }
+
+ unclicked(location) {
+ }
+}
+
+class MouseClickAction extends IMouseClick {
+
+ static #ignoreEvent =
+ /** @param {MouseClickAction} self */
+ self => { }
+
+ constructor(
+ target,
+ blueprint,
+ options,
+ onMouseDown = MouseClickAction.#ignoreEvent,
+ onMouseUp = MouseClickAction.#ignoreEvent
+ ) {
+ super(target, blueprint, options);
+ this.onMouseDown = onMouseDown;
+ this.onMouseUp = onMouseUp;
+ }
+
+ clicked() {
+ this.onMouseDown(this);
+ }
+
+ unclicked() {
+ this.onMouseUp(this);
+ }
+}
+
/**
* @template {WindowTemplate} T
* @extends {IDraggableElement
`
}
diff --git a/js/template/ColorSliderTemplate.js b/js/template/ColorSliderTemplate.js
index 6250a00..bb7f0d5 100755
--- a/js/template/ColorSliderTemplate.js
+++ b/js/template/ColorSliderTemplate.js
@@ -6,12 +6,6 @@ import Utility from "../Utility"
/** @extends {IDraggableControlTemplate
} */
export default class ColorSliderTemplate extends IDraggableControlTemplate {
- createInputObjects() {
- return [
- ...super.createInputObjects(),
- ]
- }
-
/** @param {[Number, Number]} param0 */
adjustLocation([x, y]) {
x = Utility.clamp(x, 0, this.movementSpaceSize[0])
diff --git a/js/template/IInputPinTemplate.js b/js/template/IInputPinTemplate.js
index 5840029..e46a969 100644
--- a/js/template/IInputPinTemplate.js
+++ b/js/template/IInputPinTemplate.js
@@ -1,6 +1,7 @@
import { html } from "lit"
import MouseIgnore from "../input/mouse/MouseIgnore"
import PinTemplate from "./PinTemplate"
+import Utility from "../Utility"
/**
* @template T
@@ -76,9 +77,7 @@ export default class IInputPinTemplate extends PinTemplate {
getInputs() {
return this.#inputContentElements.map(element =>
// Faster than innerText which causes reflow
- element.innerHTML
- .replaceAll(" ", "\u00A0")
- .replaceAll("
", "\n")
+ Utility.clearHTMLWhitespace(element.innerHTML)
)
}
diff --git a/js/template/LinearColorPinTemplate.js b/js/template/LinearColorPinTemplate.js
index 2687cf2..72d2428 100644
--- a/js/template/LinearColorPinTemplate.js
+++ b/js/template/LinearColorPinTemplate.js
@@ -10,6 +10,7 @@ import WindowElement from "../element/WindowElement"
* @typedef {import("../entity/LinearColorEntity").default} LinearColorEntity
*/
+/** @extends IInputPinTemplate */
export default class LinearColorPinTemplate extends IInputPinTemplate {
/** @type {HTMLInputElement} */
@@ -40,7 +41,9 @@ export default class LinearColorPinTemplate extends IInputPinTemplate {
})
this.element.blueprint.append(this.#window)
const windowApplyHandler = () => {
- this.element.color = /** @type {ColorPickerWindowTemplate} */(this.#window.template).color
+ this.element.setDefaultValue(
+ /** @type {ColorPickerWindowTemplate} */(this.#window.template).color
+ )
}
const windowCloseHandler = () => {
this.#window.removeEventListener(Configuration.windowApplyEventName, windowApplyHandler)
diff --git a/js/template/RealPinTemplate.js b/js/template/RealPinTemplate.js
index ba08703..b97c5af 100644
--- a/js/template/RealPinTemplate.js
+++ b/js/template/RealPinTemplate.js
@@ -18,9 +18,8 @@ export default class RealPinTemplate extends INumericPinTemplate {
return html`
+ .innerText="${IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.entity.DefaultValue))}">
+
`
}
diff --git a/js/template/WindowTemplate.js b/js/template/WindowTemplate.js
index cd58ead..ec1cb52 100755
--- a/js/template/WindowTemplate.js
+++ b/js/template/WindowTemplate.js
@@ -1,6 +1,6 @@
import { html } from "lit"
+import Configuration from "../Configuration"
import IDraggablePositionedTemplate from "./IDraggablePositionedTemplate"
-import MouseClickAction from "../input/mouse/MouseClickAction"
import MouseMoveDraggable from "../input/mouse/MouseMoveDraggable"
/** @typedef {import("../element/WindowElement").default} WindowElement */
@@ -23,22 +23,12 @@ export default class WindowTemplate extends IDraggablePositionedTemplate {
})
}
- createInputObjects() {
- return [
- ...super.createInputObjects(),
- new MouseClickAction(this.element.querySelector(".ueb-window-close"), this.element.blueprint, {},
- undefined,
- () => this.element.remove()
- ),
- ]
- }
-
render() {
return html`
${this.renderWindowName()}
-
+
this.element.remove()}">