SVGHMI: Input widget overrides undershot() and overshot() methods to display "min: xxx" or "max: xxx" when user input goes out of given range. svghmi
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Tue, 29 Dec 2020 15:37:41 +0100
branchsvghmi
changeset 3100 c51f9cf365c6
parent 3099 c7d14130401f
child 3101 4cbf024a6640
SVGHMI: Input widget overrides undershot() and overshot() methods to display "min: xxx" or "max: xxx" when user input goes out of given range.
svghmi/widget_input.ysl2
--- a/svghmi/widget_input.ysl2	Tue Dec 29 15:35:39 2020 +0100
+++ b/svghmi/widget_input.ysl2	Tue Dec 29 15:37:41 2020 +0100
@@ -9,6 +9,18 @@
          edit_callback(new_val) {
              this.apply_hmi_value(0, new_val);
          }
+
+         overshot(new_val, max) {
+             this.last_display = "max: "+max;
+             this.request_animate();
+         }
+
+         undershot(new_val, min) {
+             this.last_display = "min: "+min;
+             this.request_animate();
+         }
+
+
     }
 ||
 }
@@ -35,10 +47,17 @@
     if "$have_edit"
     |         this.last_val = value;
 
-    if "$have_value"
-    |         this.value_elt.textContent = String(value);
+    if "$have_value" {
+    |         this.last_display = value;
+    |         this.request_animate();
+    }
+    |     },
 
+    if "$have_value" {
+    |     animate: function(){
+    |         this.value_elt.textContent = String(this.last_display);
     |     },
+    }
 
     |     init: function() {