svghmi/widget_tooglebutton.ysl2
branchwxPython4
changeset 3609 51a3d6f39944
parent 3599 0d7c41546854
--- a/svghmi/widget_tooglebutton.ysl2	Tue Sep 13 16:51:54 2022 +0200
+++ b/svghmi/widget_tooglebutton.ysl2	Tue Sep 13 16:53:15 2022 +0200
@@ -18,33 +18,27 @@
 widget_class("ToggleButton") {
     ||
         frequency = 5;
-        state = 0;
         active_style = undefined;
         inactive_style = undefined;
 
         dispatch(value) {
-            this.state = value;
+            this.activity_state = Boolean(value);
             //redraw toggle button
             this.request_animate();
         }
 
         on_click(evt) {
             //toggle state and apply
-            this.state = this.state ? false : true;
-            this.apply_hmi_value(0, this.state);
+            this.activity_state = this.activity_state ? false : true;
+            this.apply_hmi_value(0, this.activity_state);
 
             //redraw toggle button
             this.request_animate();
         }
 
-        animate(){
-            // redraw toggle button on screen refresh
-            this.set_activation_state(this.state);
-        }
-
         init() {
             this.element.onclick = (evt) => this.on_click(evt);
-            this.set_activation_state(undefined);
+            this.activity_state = undefined;
         }
     ||
 }