Edouard@3403: // widget_switch.ysl2 Edouard@3403: Edouard@3403: widget_desc("ListSwitch") { Edouard@3403: longdesc Edouard@3403: || Edouard@3403: ListSwitch widget displays one item of an HMI:List depending on value of Edouard@3403: given variable. Main element of the widget must be a clone of the list or Edouard@3403: of an item of that list. Edouard@3403: Edouard@3403: Given variable's current value is compared to list items Edouard@3403: label. For exemple if given variable type Edouard@3403: is HMI_INT and value is 1, then item with label '1' will be displayed. Edouard@3403: If matching variable of type HMI_STRING, then no quotes are needed. Edouard@3403: For exemple, 'hello' match HMI_STRING 'hello'. Edouard@3403: || Edouard@3403: Edouard@3403: shortdesc > Displays item of an HMI:List whose label matches value. Edouard@3403: Edouard@3403: path name="value" accepts="HMI_INT,HMI_STRING" > value to compare to labels Edouard@3403: Edouard@3403: } Edouard@3403: Edouard@3403: widget_class("ListSwitch"){ Edouard@3403: || Edouard@3403: frequency = 5; Edouard@3403: || Edouard@3403: } Edouard@3403: Edouard@3403: widget_defs("ListSwitch") { Edouard@3403: // cloned element must be part of a HMI:List or a HMI:List Edouard@3403: const "targetid", "substring-after($hmi_element/@xlink:href,'#')"; Edouard@3403: const "from_list", "$hmi_lists[(@id | */@id) = $targetid]"; Edouard@3403: || Edouard@3403: dispatch: function(value) { Edouard@3403: this.element.href.baseVal = "#"+hmi_widgets["«$from_list/@id»"].items[value]; Edouard@3403: }, Edouard@3403: || Edouard@3403: }