dgaberscek@2977: // widget_tooglebutton.ysl2 dgaberscek@2977: usveticic@3011: Edouard@3024: template "widget[@type='ToggleButton']", mode="widget_class"{ usveticic@3011: || usveticic@3011: class ToggleButtonWidget extends Widget{ usveticic@3011: frequency = 5; usveticic@3011: state = 0; usveticic@3011: active_style = undefined; usveticic@3011: inactive_style = undefined; usveticic@3011: usveticic@3011: dispatch(value) { usveticic@3056: if(this.state != value){ usveticic@3056: this.state = value; usveticic@3056: if (this.state) { usveticic@3056: this.active_elt.setAttribute("style", this.active_style); usveticic@3056: this.inactive_elt.setAttribute("style", "display:none"); usveticic@3056: } else { usveticic@3056: this.inactive_elt.setAttribute("style", this.inactive_style); usveticic@3056: this.active_elt.setAttribute("style", "display:none"); usveticic@3056: } usveticic@3011: } usveticic@3011: } usveticic@3011: usveticic@3011: on_click(evt) { usveticic@3056: if (this.state) { usveticic@3056: this.inactive_elt.setAttribute("style", this.inactive_style); usveticic@3056: this.active_elt.setAttribute("style", "display:none"); usveticic@3056: this.state = 0; usveticic@3056: } else { usveticic@3056: this.active_elt.setAttribute("style", this.active_style); usveticic@3056: this.inactive_elt.setAttribute("style", "display:none"); usveticic@3056: this.state = 1; usveticic@3056: } Edouard@3018: this.apply_hmi_value(0, this.state); usveticic@3011: } usveticic@3011: usveticic@3011: init() { usveticic@3011: this.active_style = this.active_elt.style.cssText; usveticic@3011: this.inactive_style = this.inactive_elt.style.cssText; usveticic@3011: this.element.setAttribute("onclick", "hmi_widgets['"+this.element_id+"'].on_click(evt)"); usveticic@3056: this.inactive_elt.setAttribute("style", this.inactive_style); usveticic@3056: this.active_elt.setAttribute("style", "display:none"); usveticic@3011: } usveticic@3011: } usveticic@3011: || Edouard@3024: } usveticic@3011: dgaberscek@2977: template "widget[@type='ToggleButton']", mode="widget_defs" { dgaberscek@2977: param "hmi_element"; dgaberscek@2977: labels("active inactive"); usveticic@3011: |, edouard@3004: }