Allow printf-like formating in HMI:Input, usefull for example when dealing with floating point numbers. svghmi
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Fri, 19 Feb 2021 10:04:17 +0100
branchsvghmi
changeset 3153 671283404554
parent 3152 c80a5a7198ea
child 3154 a8c81a080588
Allow printf-like formating in HMI:Input, usefull for example when dealing with floating point numbers.
svghmi/widget_input.ysl2
tests/svghmi_real/svghmi_0@svghmi/svghmi.svg
--- a/svghmi/widget_input.ysl2	Fri Feb 19 10:03:00 2021 +0100
+++ b/svghmi/widget_input.ysl2	Fri Feb 19 10:04:17 2021 +0100
@@ -45,7 +45,14 @@
     |         this.last_val = value;
 
     if "$have_value" {
+        choose{
+            when "count(arg) = 1" {
+    |         this.last_display = vsprintf("«arg[1]/@value»", value);
+            }
+            otherwise {
     |         this.last_display = value;
+            }
+        }
     |         this.request_animate();
     }
     |     },
@@ -60,6 +67,9 @@
 
     if "$have_edit" {
     |         this.edit_elt.onclick = () => edit_value("«path/@value»", "«path/@type»", this, this.last_val);
+        if "$have_value" {
+    |         this.value_elt.style.pointerEvents = "none";
+        }
     }
 
     foreach "$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-].+')]" {
--- a/tests/svghmi_real/svghmi_0@svghmi/svghmi.svg	Fri Feb 19 10:03:00 2021 +0100
+++ b/tests/svghmi_real/svghmi_0@svghmi/svghmi.svg	Fri Feb 19 10:04:17 2021 +0100
@@ -60,11 +60,11 @@
      showgrid="false"
      units="px"
      inkscape:zoom="0.64"
-     inkscape:cx="544.00649"
-     inkscape:cy="385.16049"
+     inkscape:cx="106.50649"
+     inkscape:cy="372.66049"
      inkscape:window-width="1600"
      inkscape:window-height="836"
-     inkscape:window-x="0"
+     inkscape:window-x="1600"
      inkscape:window-y="27"
      inkscape:window-maximized="0"
      showguides="true"
@@ -380,7 +380,7 @@
      sodipodi:insensitive="true" />
   <g
      id="g4490"
-     inkscape:label="HMI:Input@/VAR0"
+     inkscape:label="HMI:Input:%.4f@/VAR0"
      transform="translate(220,-220)">
     <rect
        style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"