3 template "widget[@type='Button']", mode="widget_class"{ |
3 template "widget[@type='Button']", mode="widget_class"{ |
4 || |
4 || |
5 class ButtonWidget extends Widget{ |
5 class ButtonWidget extends Widget{ |
6 frequency = 5; |
6 frequency = 5; |
7 state = 0; |
7 state = 0; |
|
8 plc_lock = false; |
8 active_style = undefined; |
9 active_style = undefined; |
9 inactive_style = undefined; |
10 inactive_style = undefined; |
|
11 |
|
12 dispatch(value) { |
|
13 if(value){ |
|
14 this.button_release(); |
|
15 } |
|
16 } |
10 |
17 |
11 on_mouse_down(evt) { |
18 on_mouse_down(evt) { |
12 if (this.active_style && this.inactive_style) { |
19 if (this.active_style && this.inactive_style) { |
13 this.active_elt.setAttribute("style", this.active_style); |
20 this.active_elt.setAttribute("style", this.active_style); |
14 this.inactive_elt.setAttribute("style", "display:none"); |
21 this.inactive_elt.setAttribute("style", "display:none"); |
15 } |
22 } |
16 this.apply_hmi_value(0, 1); |
23 this.apply_hmi_value(0, 1); |
|
24 this.plc_lock = false; |
17 } |
25 } |
18 |
26 |
19 on_mouse_up(evt) { |
27 on_mouse_up(evt) { |
20 if (this.active_style && this.inactive_style) { |
28 this.button_release(); |
21 this.active_elt.setAttribute("style", "display:none"); |
29 } |
22 this.inactive_elt.setAttribute("style", this.inactive_style); |
30 |
23 } |
31 button_release(){ |
24 this.apply_hmi_value(0, 0); |
32 if(!this.plc_lock){ |
|
33 this.plc_lock = true; |
|
34 } |
|
35 else{ |
|
36 if (this.active_style && this.inactive_style) { |
|
37 this.active_elt.setAttribute("style", "display:none"); |
|
38 this.inactive_elt.setAttribute("style", this.inactive_style); |
|
39 } |
|
40 this.apply_hmi_value(0, 0); |
|
41 } |
25 } |
42 } |
26 |
43 |
27 init() { |
44 init() { |
28 this.active_style = this.active_elt ? this.active_elt.style.cssText : undefined; |
45 this.active_style = this.active_elt ? this.active_elt.style.cssText : undefined; |
29 this.inactive_style = this.inactive_elt ? this.inactive_elt.style.cssText : undefined; |
46 this.inactive_style = this.inactive_elt ? this.inactive_elt.style.cssText : undefined; |