svghmi/widget_foreach.ysl2
author Edouard Tisserant <edouard.tisserant@gmail.com>
Fri, 20 Mar 2020 10:46:15 +0100
branchsvghmi
changeset 2891 8927ae8326b2
child 2892 27dd409fba1d
permissions -rw-r--r--
SVGHMI: add widget_foreach.ysl2

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)
    |     },
}