# HG changeset patch # User Edouard Tisserant # Date 1584697575 -3600 # Node ID 8927ae8326b21b0363ff1a7eba89b5e2af1d725e # Parent ae8063127e959dc962f6cbf1f70fd61501ed092e SVGHMI: add widget_foreach.ysl2 diff -r ae8063127e95 -r 8927ae8326b2 svghmi/widget_foreach.ysl2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/svghmi/widget_foreach.ysl2 Fri Mar 20 10:46:15 2020 +0100 @@ -0,0 +1,28 @@ + +template "widget[@type='ForEach']", mode="widget_defs" { + param "hmi_element"; + | frequency: 2, + | dispatch: function(value) { + | // do something + | }, + | init: function() { + foreach "$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-].+')]" { + | id("«@id»").addEventListener( + | "click", + | evt => {let new_val = "«func:escape_quotes(@inkscape:label)»"); + | // do something with new_val + | }); + } + | }, +} + +template "widget[@type='ForEach']", mode="widget_subscribe"{ + // param "hmi_element"; + | sub: function(off){ + | subscribe.call(this,off) + | }, + + | unsub: function(){ + | unsubscribe.call(this) + | }, +}