# HG changeset patch
# User Edouard Tisserant
# Date 1615803924 -3600
# Node ID c173452bf894c91955e10e8b389a558433167039
# Parent ba8ff21fd82b7a7dc3eba8f08fb09ac57bbed940
SVGHMI: Fixed problems happening when value is higher than maximum or lower than minimum in Input widget. "max" and "min" string was getting into keypad text field, was not diplayed systematically, and was staying forever sometime.
diff -r ba8ff21fd82b -r c173452bf894 svghmi/gen_index_xhtml.xslt
--- a/svghmi/gen_index_xhtml.xslt Fri Mar 12 15:12:38 2021 +0100
+++ b/svghmi/gen_index_xhtml.xslt Mon Mar 15 11:25:24 2021 +0100
@@ -4422,11 +4422,37 @@
+ 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.last_display = "max: "+max;
-
- this.request_animate();
+ this.alert("max");
}
@@ -4434,9 +4460,7 @@
undershot(new_val, min) {
- this.last_display = "min: "+min;
-
- this.request_animate();
+ this.alert("min");
}
@@ -4480,19 +4504,25 @@
- this.last_display = vsprintf("
+ this.last_value = vsprintf("
", [value]);
- this.last_display = value;
+ this.last_value = value;
-
-
- this.request_animate();
+ if(!this.is_inhibited){
+
+ this.display = this.last_value;
+
+
+ this.request_animate();
+
+
+ }
},
@@ -4500,7 +4530,7 @@
animate: function(){
- this.value_elt.textContent = String(this.last_display);
+ this.value_elt.textContent = String(this.display);
},
@@ -4512,7 +4542,7 @@
", "
- ", this, this.last_display);
+ ", this, this.last_value);
this.value_elt.style.pointerEvents = "none";
diff -r ba8ff21fd82b -r c173452bf894 svghmi/widget_input.ysl2
--- 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";
}