--- a/svghmi/widget_foreach.ysl2 Wed Oct 16 15:45:15 2024 +0200
+++ b/svghmi/widget_foreach.ysl2 Wed Oct 16 15:45:43 2024 +0200
@@ -5,7 +5,7 @@
ForEach widget is used to span a small set of widget over a larger set of
Idea is somewhat similar to relative page, but it all happens inside the
ForEach widget, no page involved.
@@ -45,8 +45,8 @@
const "hmi_index_base", "$indexed_hmitree/*[@hmipath = $base_path]";
const "hmi_tree_base", "$hmitree/descendant-or-self::*[@path = $hmi_index_base/@path]";
const "hmi_tree_items", "$hmi_tree_base/*[@class = $class]";
- const "hmi_index_items", "$indexed_hmitree/*[@path = $hmi_tree_items/@path]";
- const "items_paths", "$hmi_index_items/@hmipath";
+ const "hmi_index_items", "$indexed_hmitree/*[@path = $hmi_tree_items/@path]"; + const "items_paths", "$hmi_index_items/@hmipath"; foreach "$hmi_index_items" {
| «@index»`if "position()!=last()" > ,`
@@ -55,7 +55,7 @@
const "prefix","concat($class,':')";
const "buttons_regex","concat('^',$prefix,'[+\-][0-9]+')";
- const "buttons", "$hmi_element/*[regexp:test(@inkscape:label, $buttons_regex)]";
+ const "buttons", "$hmi_element/*[regexp:test(@inkscape:label, $buttons_regex)]"; const "op","substring-after(@inkscape:label, $prefix)";
| id("«@id»").setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_click('«$op»', evt)");
@@ -65,7 +65,7 @@
const "items_regex","concat('^',$prefix,'[0-9]+')";
const "unordered_items","$hmi_element//*[regexp:test(@inkscape:label, $items_regex)]";
foreach "$unordered_items" {
- const "elt_label","concat($prefix, string(position()))";
+ const "elt_label","concat($prefix, string(position()))"; const "elt","$unordered_items[@inkscape:label = $elt_label]";
const "pos","position()";
const "item_path", "$items_paths[$pos]";