svghmi/widget_input.ysl2
branchsvghmi
changeset 2911 211d6a185e31
parent 2910 1a1caf71b1cc
child 2917 c8d923dd707f
equal deleted inserted replaced
2910:1a1caf71b1cc 2911:211d6a185e31
     7     }
     7     }
     8     const "have_value","string-length($value_elt)>0";
     8     const "have_value","string-length($value_elt)>0";
     9     value "$value_elt";
     9     value "$value_elt";
    10     if "$have_value"
    10     if "$have_value"
    11     |     frequency: 5,
    11     |     frequency: 5,
    12 
    12     |     last_val: undefined,
    13     |     dispatch: function(value) {
    13     |     dispatch: function(value) {
    14 
    14     |         this.last_val = value;
    15     if "$have_value"
    15     if "$have_value"
    16     |         this.value_elt.textContent = String(value);
    16     |         this.value_elt.textContent = String(value);
    17 
    17 
    18     |     },
    18     |     },
    19     const "edit_elt_id","$hmi_element/*[@inkscape:label='edit'][1]/@id";
    19     const "edit_elt_id","$hmi_element/*[@inkscape:label='edit'][1]/@id";
    20     |     init: function() {
    20     |     init: function() {
    21     if "$edit_elt_id" {
    21     if "$edit_elt_id" {
    22     |         id("«$edit_elt_id»").addEventListener(
    22     |         id("«$edit_elt_id»").setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_edit_click()");
    23     |             "click", 
       
    24     |             evt => alert('XXX TODO : Edit value'));
       
    25     }
    23     }
    26     foreach "$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-].+')]" {
    24     foreach "$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-].+')]" {
    27     |         id("«@id»").setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_op_click('«func:escape_quotes(@inkscape:label)»')");
    25     |         id("«@id»").setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_op_click('«func:escape_quotes(@inkscape:label)»')");
    28     }
    26     }
    29     |     },
    27     |     },
    32         if "$have_value"{
    30         if "$have_value"{
    33     |         this.value_elt.textContent = String(new_val);
    31     |         this.value_elt.textContent = String(new_val);
    34               /* TODO gray out value until refreshed */
    32               /* TODO gray out value until refreshed */
    35         }
    33         }
    36     |     },
    34     |     },
       
    35     |     on_edit_click: function(opstr) {
       
    36     |         edit_value("«path/@value»", "«path/@type»", this.edit_callback, this.last_val);
       
    37     |     },
       
    38 
       
    39     |     edit_callback: function(new_val) {
       
    40     |         apply_hmi_value(this.indexes[0], opstr);
       
    41         if "$have_value"{
       
    42     |         this.value_elt.textContent = String(new_val);
       
    43               /* TODO gray out value until refreshed */
       
    44         }
       
    45     |     },
    37 }
    46 }