SVGHMI: fix probable problem in HMI:Input, where value could be applied to wrong index if used in relative page. svghmi
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Tue, 14 Apr 2020 17:16:25 +0200
branchsvghmi
changeset 2929 9179cbc6fc49
parent 2928 c73d0b042ca8
child 2930 41edcb8e0a01
SVGHMI: fix probable problem in HMI:Input, where value could be applied to wrong index if used in relative page.
svghmi/widget_input.ysl2
--- a/svghmi/widget_input.ysl2	Tue Apr 14 17:15:02 2020 +0200
+++ b/svghmi/widget_input.ysl2	Tue Apr 14 17:16:25 2020 +0200
@@ -26,7 +26,9 @@
     }
     |     },
     |     on_op_click: function(opstr) {
-    |         let new_val = change_hmi_value(this.indexes[0], opstr);
+    |         let orig = this.indexes[0];
+    |         let idx = this.offset ? orig - this.offset : orig;
+    |         let new_val = change_hmi_value(idx, opstr);
     //     if "$have_value"{
     // |         this.value_elt.textContent = String(new_val);
     //           /* TODO gray out value until refreshed */
@@ -37,7 +39,9 @@
     |     },
 
     |     edit_callback: function(new_val) {
-    |         apply_hmi_value(this.indexes[0], new_val);
+    |         let orig = this.indexes[0];
+    |         let idx = this.offset ? orig - this.offset : orig;
+    |         apply_hmi_value(idx, new_val);
     //     if "$have_value"{
     // |         this.value_elt.textContent = String(new_val);
     //           /* TODO gray out value until refreshed */