equal
deleted
inserted
replaced
|
1 // widget_switch.ysl2 |
|
2 |
|
3 widget_desc("ListSwitch") { |
|
4 longdesc |
|
5 || |
|
6 ListSwitch widget displays one item of an HMI:List depending on value of |
|
7 given variable. Main element of the widget must be a clone of the list or |
|
8 of an item of that list. |
|
9 |
|
10 Given variable's current value is compared to list items |
|
11 label. For exemple if given variable type |
|
12 is HMI_INT and value is 1, then item with label '1' will be displayed. |
|
13 If matching variable of type HMI_STRING, then no quotes are needed. |
|
14 For exemple, 'hello' match HMI_STRING 'hello'. |
|
15 || |
|
16 |
|
17 shortdesc > Displays item of an HMI:List whose label matches value. |
|
18 |
|
19 path name="value" accepts="HMI_INT,HMI_STRING" > value to compare to labels |
|
20 |
|
21 } |
|
22 |
|
23 widget_class("ListSwitch"){ |
|
24 || |
|
25 frequency = 5; |
|
26 || |
|
27 } |
|
28 |
|
29 widget_defs("ListSwitch") { |
|
30 // cloned element must be part of a HMI:List or a HMI:List |
|
31 const "targetid", "substring-after($hmi_element/@xlink:href,'#')"; |
|
32 const "from_list", "$hmi_lists[(@id | */@id) = $targetid]"; |
|
33 || |
|
34 dispatch: function(value) { |
|
35 this.element.href.baseVal = "#"+hmi_widgets["«$from_list/@id»"].items[value]; |
|
36 }, |
|
37 || |
|
38 } |