--- a/svghmi/widget_tooglebutton.ysl2 Mon Jun 20 09:19:56 2022 +0200
+++ b/svghmi/widget_tooglebutton.ysl2 Mon Jun 20 09:30:11 2022 +0200
@@ -37,22 +37,51 @@
- let [active, inactive] = val ? ["","none"] : ["none", ""];
- this.active_elt.style.display = active;
- this.inactive_elt.style.display = inactive;
+ if(active==undefined || !active){ + if(this.active_elt_parent == undefined){ + this.active_elt_parent = this.active_elt.parentElement; + this.active_elt_parent.removeChild(this.active_elt); + if(this.active_elt_parent != undefined){ + this.active_elt_parent.insertBefore(this.active_elt, this.active_elt_sibling); + this.active_elt_parent = undefined; + if (this.inactive_elt){ + if(active==undefined || active){ + if(this.inactive_elt_parent == undefined){ + this.inactive_elt_parent = this.inactive_elt.parentElement; + this.inactive_elt_parent.removeChild(this.inactive_elt); + if(this.inactive_elt_parent != undefined){ + this.inactive_elt_parent.insertBefore(this.inactive_elt, this.inactive_elt_sibling); + this.inactive_elt_parent = undefined; // redraw toggle button on screen refresh
- this.activate(this.state);
+ this.set_state(this.state);
this.element.onclick = (evt) => this.on_click(evt);
+ this.active_elt_parent = undefined; + this.active_elt_sibling = this.active_elt.nextSibling; + this.inactive_elt_parent = undefined; + this.inactive_elt_sibling = this.inactive_elt.nextSibling; + if(this.inactive_elt_sibling == this.active_elt) + this.inactive_elt_sibling = this.inactive_elt_sibling.nextSibling; + if(this.active_elt_sibling == this.inactive_elt) + this.active_elt_sibling = this.active_elt_sibling.nextSibling; + this.set_state(undefined); @@ -60,3 +89,4 @@
widget_defs("ToggleButton") {
optional_labels("active inactive");