edouard@2883: // widget_input.ysl2 Edouard@2779: edouard@2883: template "widget[@type='Input']", mode="widget_defs" { edouard@2883: param "hmi_element"; edouard@2883: const "value_elt" { edouard@2883: optional_labels("value"); edouard@2883: } edouard@2883: const "have_value","string-length($value_elt)>0"; edouard@2883: value "$value_elt"; edouard@2883: if "$have_value" edouard@2883: | frequency: 5, Edouard@2911: | last_val: undefined, edouard@2883: | dispatch: function(value) { Edouard@2911: | this.last_val = value; edouard@2883: if "$have_value" edouard@2883: | this.value_elt.textContent = String(value); Edouard@2836: edouard@2883: | }, edouard@2883: const "edit_elt_id","$hmi_element/*[@inkscape:label='edit'][1]/@id"; edouard@2883: | init: function() { edouard@2883: if "$edit_elt_id" { Edouard@2911: | id("«$edit_elt_id»").setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_edit_click()"); edouard@2883: } edouard@2883: foreach "$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-].+')]" { Edouard@2910: | id("«@id»").setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_op_click('«func:escape_quotes(@inkscape:label)»')"); Edouard@2792: } edouard@2883: | }, Edouard@2910: | on_op_click: function(opstr) { Edouard@2910: | let new_val = change_hmi_value(this.indexes[0], opstr); Edouard@2910: if "$have_value"{ Edouard@2910: | this.value_elt.textContent = String(new_val); Edouard@2910: /* TODO gray out value until refreshed */ Edouard@2910: } Edouard@2910: | }, Edouard@2911: | on_edit_click: function(opstr) { Edouard@2917: | edit_value("«path/@value»", "«path/@type»", this, this.last_val); Edouard@2911: | }, Edouard@2911: Edouard@2911: | edit_callback: function(new_val) { Edouard@2917: | apply_hmi_value(this.indexes[0], new_val); Edouard@2911: if "$have_value"{ Edouard@2911: | this.value_elt.textContent = String(new_val); Edouard@2911: /* TODO gray out value until refreshed */ Edouard@2911: } Edouard@2911: | }, Edouard@2753: }