edouard@2883: // widget_input.ysl2 Edouard@2779: edouard@2883: template "widget[@type='Input']", mode="widget_defs" { edouard@2883: param "hmi_element"; usveticic@3010: optional_labels("key_pos"); 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@3004: | let new_val = this.change_hmi_value(0, opstr); Edouard@2921: // if "$have_value"{ Edouard@2921: // | this.value_elt.textContent = String(new_val); Edouard@2921: // /* TODO gray out value until refreshed */ Edouard@2921: // } Edouard@2910: | }, Edouard@2911: | on_edit_click: function(opstr) { usveticic@3010: | var size = (typeof this.key_pos_elt !== 'undefined') ? this.key_pos_elt.getBBox() : undefined usveticic@3010: | edit_value("«path/@value»", "«path/@type»", this, this.last_val,size); Edouard@2911: | }, Edouard@2911: Edouard@2911: | edit_callback: function(new_val) { edouard@3004: | this.apply_hmi_value(0, new_val); Edouard@2921: // if "$have_value"{ Edouard@2921: // | this.value_elt.textContent = String(new_val); Edouard@2921: // /* TODO gray out value until refreshed */ Edouard@2921: // } Edouard@2911: | }, Edouard@2753: }