dgaberscek@2944: // widget_button.ysl2 dgaberscek@2944: dgaberscek@2976: template "widget[@type='Button']", mode="widget_defs" { dgaberscek@2976: param "hmi_element"; dgaberscek@2976: optional_labels("active inactive"); dgaberscek@2976: | frequency: 5, dgaberscek@2976: | on_mouse_down: function(evt) { dgaberscek@2976: | if (this.active_style && this.inactive_style) { dgaberscek@2976: | this.active_elt.setAttribute("style", this.active_style); dgaberscek@2976: | this.inactive_elt.setAttribute("style", "display:none"); dgaberscek@2976: | } edouard@3000: | apply_hmi_value(this.get_idx(0), 1); dgaberscek@2976: | }, dgaberscek@2976: | on_mouse_up: function(evt) { dgaberscek@2976: | if (this.active_style && this.inactive_style) { dgaberscek@2976: | this.active_elt.setAttribute("style", "display:none"); dgaberscek@2976: | this.inactive_elt.setAttribute("style", this.inactive_style); dgaberscek@2976: | } edouard@3000: | apply_hmi_value(this.get_idx(0), 0); dgaberscek@2976: | }, dgaberscek@2976: | active_style: undefined, dgaberscek@2976: | inactive_style: undefined, dgaberscek@2976: | init: function() { dgaberscek@2976: | this.active_style = this.active_elt ? this.active_elt.style.cssText : undefined; dgaberscek@2976: | this.inactive_style = this.inactive_elt ? this.inactive_elt.style.cssText : undefined; dgaberscek@2976: | if (this.active_style && this.inactive_style) { dgaberscek@2976: | this.active_elt.setAttribute("style", "display:none"); dgaberscek@2976: | this.inactive_elt.setAttribute("style", this.inactive_style); dgaberscek@2976: | } dgaberscek@2976: | this.element.setAttribute("onmousedown", "hmi_widgets['«$hmi_element/@id»'].on_mouse_down(evt)"); dgaberscek@2976: | this.element.setAttribute("onmouseup", "hmi_widgets['«$hmi_element/@id»'].on_mouse_up(evt)"); dgaberscek@2976: | }, edouard@3000: }