svghmi/widget_input.ysl2
branchsvghmi
changeset 3188 c173452bf894
parent 3155 99ce78ddd353
child 3232 7bdb766c2a4d
--- a/svghmi/widget_input.ysl2	Fri Mar 12 15:12:38 2021 +0100
+++ b/svghmi/widget_input.ysl2	Mon Mar 15 11:25:24 2021 +0100
@@ -10,14 +10,26 @@
              this.apply_hmi_value(0, new_val);
          }
 
-         overshot(new_val, max) {
-             this.last_display = "max: "+max;
+         is_inhibited = false;
+         alert(msg){
+             this.is_inhibited = true;
+             this.display = msg;
+             setTimeout(() => this.stopalert(), 1000);
              this.request_animate();
          }
 
+         stopalert(){
+             this.is_inhibited = false;
+             this.display = this.last_value;
+             this.request_animate();
+         }
+
+         overshot(new_val, max) {
+             this.alert("max");
+         }
+
          undershot(new_val, min) {
-             this.last_display = "min: "+min;
-             this.request_animate();
+             this.alert("min");
          }
 
 
@@ -45,28 +57,31 @@
     if "$have_value or $have_edit" {
         choose{
             when "count(arg) = 1" {
-    |         this.last_display = vsprintf("«arg[1]/@value»", [value]);
+    |         this.last_value = vsprintf("«arg[1]/@value»", [value]);
             }
             otherwise {
-    |         this.last_display = value;
+    |         this.last_value = value;
             }
         }
+    |         if(!this.is_inhibited){
+    |             this.display = this.last_value;
+    if "$have_value" {
+    |             this.request_animate();
     }
-    if "$have_value" {
-    |         this.request_animate();
+    |         }
     }
     |     },
 
     if "$have_value" {
     |     animate: function(){
-    |         this.value_elt.textContent = String(this.last_display);
+    |         this.value_elt.textContent = String(this.display);
     |     },
     }
 
     |     init: function() {
 
     if "$have_edit" {
-    |         this.edit_elt.onclick = () => edit_value("«path/@value»", "«path/@type»", this, this.last_display);
+    |         this.edit_elt.onclick = () => edit_value("«path/@value»", "«path/@type»", this, this.last_value);
         if "$have_value" {
     |         this.value_elt.style.pointerEvents = "none";
         }