edouard@2883: // widget_input.ysl2 Edouard@2779: edouard@3094: template "widget[@type='Input']", mode="widget_class"{ edouard@3094: || edouard@3094: class InputWidget extends Widget{ edouard@3094: on_op_click(opstr) { edouard@3094: let new_val = this.change_hmi_value(0, opstr); edouard@3094: } edouard@3094: edit_callback(new_val) { edouard@3094: this.apply_hmi_value(0, new_val); edouard@3094: } edouard@3094: } edouard@3094: || edouard@3094: } edouard@3094: edouard@2883: template "widget[@type='Input']", mode="widget_defs" { edouard@2883: param "hmi_element"; edouard@3094: edouard@3094: const "key_pos_elt" optional_labels("key_pos"); edouard@3094: value "$key_pos_elt"; edouard@3094: edouard@3094: const "value_elt" optional_labels("value"); edouard@2883: const "have_value","string-length($value_elt)>0"; edouard@2883: value "$value_elt"; edouard@3094: edouard@3094: const "edit_elt" optional_labels("edit"); edouard@3094: const "have_edit","string-length($edit_elt)>0"; edouard@3094: value "$edit_elt"; edouard@3094: edouard@2883: if "$have_value" edouard@2883: | frequency: 5, edouard@3094: edouard@2883: | dispatch: function(value) { edouard@3094: edouard@3094: if "$have_edit" Edouard@2911: | this.last_val = value; edouard@3094: edouard@2883: if "$have_value" edouard@2883: | this.value_elt.textContent = String(value); Edouard@2836: edouard@2883: | }, edouard@3094: edouard@2883: | init: function() { edouard@3094: edouard@3094: if "$have_edit" { edouard@3094: | this.edit_elt.onclick = () => edit_value( edouard@3094: | "«path/@value»", "«path/@type»", edouard@3094: | this, this.last_val, edouard@3094: choose { edouard@3094: when "string-length($key_pos_elt)>0" edouard@3094: | this.key_pos_elt.getBBox() edouard@3094: otherwise edouard@3094: | undefined edouard@3094: } edouard@3094: | ); edouard@2883: } edouard@3094: edouard@2883: foreach "$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-].+')]" { edouard@3094: | id("«@id»").onclick = () => this.on_op_click("«func:escape_quotes(@inkscape:label)»"); Edouard@2792: } Edouard@2911: Edouard@2911: | }, Edouard@2753: }