2977
|
1 |
// widget_tooglebutton.ysl2
|
|
2 |
|
|
3 |
template "widget[@type='ToggleButton']", mode="widget_defs" {
|
|
4 |
param "hmi_element";
|
|
5 |
labels("active inactive");
|
|
6 |
| frequency: 5,
|
|
7 |
| state: 0,
|
|
8 |
| dispatch: function(value) {
|
|
9 |
| this.state = value;
|
|
10 |
| if (this.state) {
|
|
11 |
| this.active_elt.setAttribute("style", this.active_style);
|
|
12 |
| this.inactive_elt.setAttribute("style", "display:none");
|
|
13 |
| this.state = 0;
|
|
14 |
| } else {
|
|
15 |
| this.inactive_elt.setAttribute("style", this.inactive_style);
|
|
16 |
| this.active_elt.setAttribute("style", "display:none");
|
|
17 |
| this.state = 1;
|
|
18 |
| }
|
|
19 |
| },
|
|
20 |
| on_click: function(evt) {
|
|
21 |
| change_hmi_value(this.indexes[0], "="+this.state);
|
|
22 |
| },
|
|
23 |
| active_style: undefined,
|
|
24 |
| inactive_style: undefined,
|
|
25 |
| init: function() {
|
|
26 |
| this.active_style = this.active_elt.style.cssText;
|
|
27 |
| this.inactive_style = this.inactive_elt.style.cssText;
|
|
28 |
| this.element.setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_click(evt)");
|
|
29 |
| },
|
|
30 |
} |