svghmi/widget_keypad.ysl2
changeset 3508 14d696d7d54e
parent 3241 fe945f1f48b7
child 3520 b27e50143083
equal deleted inserted replaced
3507:e87a2daace80 3508:14d696d7d54e
    28 widget_class("Keypad")
    28 widget_class("Keypad")
    29     ||
    29     ||
    30          on_key_click(symbols) {
    30          on_key_click(symbols) {
    31              var syms = symbols.split(" ");
    31              var syms = symbols.split(" ");
    32              this.shift |= this.caps;
    32              this.shift |= this.caps;
       
    33              if(this.virgin)
       
    34                  this.editstr = ""; 
    33              this.editstr += syms[this.shift?syms.length-1:0];
    35              this.editstr += syms[this.shift?syms.length-1:0];
    34              this.shift = false;
    36              this.shift = false;
    35              this.update();
    37              this.update();
    36          }
    38          }
    37 
    39 
    96          result_callback_obj = undefined;
    98          result_callback_obj = undefined;
    97          start_edit(info, valuetype, callback_obj, initial,size) {
    99          start_edit(info, valuetype, callback_obj, initial,size) {
    98              show_modal.call(this,size);
   100              show_modal.call(this,size);
    99              this.editstr = String(initial);
   101              this.editstr = String(initial);
   100              this.result_callback_obj = callback_obj;
   102              this.result_callback_obj = callback_obj;
   101              this.Info_elt.textContent = info;
   103              if(this.Info_elt)
       
   104                  this.Info_elt.textContent = info;
   102              this.shift = false;
   105              this.shift = false;
   103              this.caps = false;
   106              this.caps = false;
   104              this.initial = initial;
   107              this.initial = initial;
   105 
   108 
   106              this.update();
   109              this.update();
       
   110              this.virgin = true;
   107          }
   111          }
   108 
   112 
   109          update() {
   113          update() {
   110              if(this.editstr != this._editstr){
   114              if(this.editstr != this._editstr){
       
   115                  this.virgin = false;
   111                  this._editstr = this.editstr;
   116                  this._editstr = this.editstr;
   112                  this.Value_elt.textContent = this.editstr;
   117                  this.Value_elt.textContent = this.editstr;
   113              }
   118              }
   114              if(this.Shift_sub && this.shift != this._shift){
   119              if(this.Shift_sub && this.shift != this._shift){
   115                  this._shift = this.shift;
   120                  this._shift = this.shift;
   121              }
   126              }
   122          }
   127          }
   123     ||
   128     ||
   124 
   129 
   125 widget_defs("Keypad") {
   130 widget_defs("Keypad") {
   126     labels("Esc Enter BackSpace Keys Info Value");
   131     labels("Esc Enter BackSpace Keys Value");
   127     optional_labels("Sign Space NumDot");
   132     optional_labels("Sign Space NumDot Info");
   128     activable_labels("CapsLock Shift");
   133     activable_labels("CapsLock Shift");
   129     |     init: function() {
   134     |     init: function() {
   130     foreach "$hmi_element/*[@inkscape:label = 'Keys']/*" {
   135     foreach "$hmi_element/*[@inkscape:label = 'Keys']/*" {
   131     |         id("«@id»").setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_key_click('«func:escape_quotes(@inkscape:label)»')");
   136     |         id("«@id»").setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_key_click('«func:escape_quotes(@inkscape:label)»')");
   132     }
   137     }
   136     }
   141     }
   137     |     },
   142     |     },
   138     |
   143     |
   139     const "g", "$geometry[@Id = $hmi_element/@id]"; 
   144     const "g", "$geometry[@Id = $hmi_element/@id]"; 
   140     |     coordinates: [«$g/@x», «$g/@y»],
   145     |     coordinates: [«$g/@x», «$g/@y»],
       
   146     |     virgin: false,
   141 }
   147 }