svghmi/widget_foreach.ysl2
branchsvghmi
changeset 2891 8927ae8326b2
child 2892 27dd409fba1d
equal deleted inserted replaced
2890:ae8063127e95 2891:8927ae8326b2
       
     1 
       
     2 template "widget[@type='ForEach']", mode="widget_defs" {
       
     3     param "hmi_element";
       
     4     |     frequency: 2,
       
     5     |     dispatch: function(value) {
       
     6     |                     // do something
       
     7     |     },
       
     8     |     init: function() {
       
     9     foreach "$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-].+')]" {
       
    10     |         id("«@id»").addEventListener(
       
    11     |             "click", 
       
    12     |             evt => {let new_val = "«func:escape_quotes(@inkscape:label)»");
       
    13     |                     // do something with new_val
       
    14     |                    });
       
    15     }
       
    16     |     },
       
    17 }
       
    18 
       
    19 template "widget[@type='ForEach']", mode="widget_subscribe"{
       
    20     // param "hmi_element";
       
    21     |     sub: function(off){
       
    22     |         subscribe.call(this,off)
       
    23     |     },
       
    24 
       
    25     |     unsub: function(){
       
    26     |         unsubscribe.call(this)
       
    27     |     },
       
    28 }