svghmi/widget_button.ysl2
branchsvghmi
changeset 3039 5ca37a7b89e2
parent 3037 da51baea69cb
child 3058 6ea4b7e1a9ed
equal deleted inserted replaced
3038:92101729f7b7 3039:5ca37a7b89e2
     6         frequency = 5;
     6         frequency = 5;
     7         state = 0;
     7         state = 0;
     8         active_style = undefined;
     8         active_style = undefined;
     9         inactive_style = undefined;
     9         inactive_style = undefined;
    10 
    10 
    11          on_mouse_down(evt) {
    11         // TODO decouple update of DOM from event (i.e use animate())
    12              if (this.active_style && this.inactive_style) {
       
    13                  this.active_elt.setAttribute("style", this.active_style);
       
    14                  this.inactive_elt.setAttribute("style", "display:none");
       
    15              }
       
    16              this.apply_hmi_value(0, 1);
       
    17          }
       
    18 
    12 
    19          on_mouse_up(evt) {
       
    20              if (this.active_style && this.inactive_style) {
       
    21                  this.active_elt.setAttribute("style", "display:none");
       
    22                  this.inactive_elt.setAttribute("style", this.inactive_style);
       
    23              }
       
    24              this.apply_hmi_value(0, 0);
       
    25          }
       
    26 
    13 
    27          init() {
    14         // TODO State of the button should distinguish UI feedbak from current PLC value
    28             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;
       
    30 
    15 
       
    16         on_mouse_down(evt) {
       
    17             if (this.active_style && this.inactive_style) {
       
    18                 this.active_elt.setAttribute("style", this.active_style);
       
    19                 this.inactive_elt.setAttribute("style", "display:none");
       
    20             }
       
    21             this.apply_hmi_value(0, 1);
       
    22             // TODO inhibit all mouse/touch events except mouse up (in other word grab cursor)
       
    23         }
       
    24 
       
    25         on_mouse_up(evt) {
    31             if (this.active_style && this.inactive_style) {
    26             if (this.active_style && this.inactive_style) {
    32                 this.active_elt.setAttribute("style", "display:none");
    27                 this.active_elt.setAttribute("style", "display:none");
    33                 this.inactive_elt.setAttribute("style", this.inactive_style);
    28                 this.inactive_elt.setAttribute("style", this.inactive_style);
    34             }
    29             }
       
    30             this.apply_hmi_value(0, 0);
       
    31             // TODO release inhibited events 
       
    32         }
    35 
    33 
    36             this.element.setAttribute("onmousedown", "hmi_widgets[\""+this.element_id+"\"].on_mouse_down(evt)");
    34         init() {
    37             this.element.setAttribute("onmouseup", "hmi_widgets[\""+this.element_id+"\"].on_mouse_up(evt)");
    35            // TODO : move to widget_defs so that we can have generated string literals directly
    38          }
    36            this.active_style = this.active_elt ? this.active_elt.style.cssText : undefined;
       
    37            this.inactive_style = this.inactive_elt ? this.inactive_elt.style.cssText : undefined;
       
    38 
       
    39            if (this.active_style && this.inactive_style) {
       
    40                this.active_elt.setAttribute("style", "display:none");
       
    41                this.inactive_elt.setAttribute("style", this.inactive_style);
       
    42            }
       
    43 
       
    44            this.element.setAttribute("onmousedown", "hmi_widgets[\""+this.element_id+"\"].on_mouse_down(evt)");
       
    45            this.element.setAttribute("onmouseup", "hmi_widgets[\""+this.element_id+"\"].on_mouse_up(evt)");
       
    46         }
    39     }
    47     }
    40     ||
    48     ||
    41 }
    49 }
    42 
    50 
    43 
    51