dgaberscek@2944: // widget_button.ysl2 dgaberscek@2944: usveticic@3009: template "widget[@type='Button']", mode="widget_class" usveticic@3009: || usveticic@3009: class ButtonWidget extends Widget{ usveticic@3009: frequency = 5; usveticic@3009: state = 0; usveticic@3009: active_style = undefined; usveticic@3009: inactive_style = undefined; usveticic@3009: usveticic@3009: on_mouse_down(evt) { usveticic@3009: if (this.active_style && this.inactive_style) { usveticic@3009: this.active_elt.setAttribute("style", this.active_style); usveticic@3009: this.inactive_elt.setAttribute("style", "display:none"); usveticic@3009: } Edouard@3018: this.apply_hmi_value(0, 1); usveticic@3009: } usveticic@3009: usveticic@3009: on_mouse_up(evt) { usveticic@3009: if (this.active_style && this.inactive_style) { usveticic@3009: this.active_elt.setAttribute("style", "display:none"); usveticic@3009: this.inactive_elt.setAttribute("style", this.inactive_style); usveticic@3009: } Edouard@3018: this.apply_hmi_value(0, 0); usveticic@3009: } usveticic@3009: usveticic@3009: init() { usveticic@3009: this.active_style = this.active_elt ? this.active_elt.style.cssText : undefined; usveticic@3009: this.inactive_style = this.inactive_elt ? this.inactive_elt.style.cssText : undefined; usveticic@3009: usveticic@3009: if (this.active_style && this.inactive_style) { usveticic@3009: this.active_elt.setAttribute("style", "display:none"); usveticic@3009: this.inactive_elt.setAttribute("style", this.inactive_style); usveticic@3009: } usveticic@3009: Edouard@3018: this.element.setAttribute("onmousedown", "hmi_widgets["+this.element_id+"].on_mouse_down(evt)"); Edouard@3018: this.element.setAttribute("onmouseup", "hmi_widgets["+this.element_id+"].on_mouse_up(evt)"); usveticic@3009: } usveticic@3009: } usveticic@3009: || usveticic@3009: usveticic@3009: dgaberscek@2976: template "widget[@type='Button']", mode="widget_defs" { dgaberscek@2976: param "hmi_element"; dgaberscek@2976: optional_labels("active inactive"); usveticic@3009: |, edouard@3000: }