SVGHMI: Widget input buttons should be clickable through svg:use (onclick attribute instead of addEventListener)
--- 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 */
+ }
+ | },
}