SVGHMI: Widget input buttons should be clickable through svg:use (onclick attribute instead of addEventListener) svghmi
authorEdouard Tisserant
Thu, 02 Apr 2020 09:38:53 +0200
branchsvghmi
changeset 2910 1a1caf71b1cc
parent 2908 01352aca1cae
child 2911 211d6a185e31
SVGHMI: Widget input buttons should be clickable through svg:use (onclick attribute instead of addEventListener)
svghmi/widget_input.ysl2
--- a/svghmi/widget_input.ysl2	Wed Apr 01 14:42:50 2020 +0200
+++ b/svghmi/widget_input.ysl2	Thu Apr 02 09:38:53 2020 +0200
@@ -24,14 +24,14 @@
     |             evt => alert('XXX TODO : Edit value'));
     }
     foreach "$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-].+')]" {
-    |         id("«@id»").addEventListener(
-    |             "click", 
-    |             evt => {let new_val = change_hmi_value(this.indexes[0], "«func:escape_quotes(@inkscape:label)»");
-        if "$have_value"{
-    |                     this.value_elt.textContent = String(new_val);
-        }
-    |                    });
-                          /* TODO gray out value until refreshed */
+    |         id("«@id»").setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_op_click('«func:escape_quotes(@inkscape:label)»')");
     }
     |     },
+    |     on_op_click: function(opstr) {
+    |         let new_val = change_hmi_value(this.indexes[0], opstr);
+        if "$have_value"{
+    |         this.value_elt.textContent = String(new_val);
+              /* TODO gray out value until refreshed */
+        }
+    |     },
 }