svghmi/widget_button.ysl2
branchsvghmi
changeset 3241 fe945f1f48b7
parent 3232 7bdb766c2a4d
child 3413 2e84a2782295
equal deleted inserted replaced
3238:8a9d4c794cba 3241:fe945f1f48b7
     1 // widget_button.ysl2
     1 // widget_button.ysl2
       
     2 
       
     3 widget_desc("Button") {
       
     4     longdesc
       
     5     ||
       
     6     Button widget takes one boolean variable path, and reflect current true
       
     7     or false value by showing "active" or "inactive" labeled element
       
     8     respectively. Pressing and releasing button changes variable to true and
       
     9     false respectively. Potential inconsistency caused by quick consecutive
       
    10     presses on the button is mitigated by using a state machine that wait for
       
    11     previous state change to be reflected on variable before applying next one.
       
    12     ||
       
    13 
       
    14     shortdesc > Push button reflecting consistently given boolean variable
       
    15 
       
    16     path name="value" accepts="HMI_BOOL" > Boolean variable
       
    17     
       
    18 }
     2 
    19 
     3 // Finite state machine
    20 // Finite state machine
     4 decl fsm(name);
    21 decl fsm(name);
     5 decl state(name);
    22 decl state(name);
     6 decl on_mouse(position);
    23 decl on_mouse(position);
   149     |         this.element.addEventListener("pointerdown", this.onmousedown.bind(this));
   166     |         this.element.addEventListener("pointerdown", this.onmousedown.bind(this));
   150     |     }
   167     |     }
   151 }
   168 }
   152 
   169 
   153 widget_defs("Button") {
   170 widget_defs("Button") {
   154     param "hmi_element";
       
   155     optional_labels("active inactive");
   171     optional_labels("active inactive");
   156 }
   172 }