svghmi/widget_input.ysl2
author usveticic
Wed, 05 Aug 2020 15:13:59 +0200
branchsvghmi
changeset 3010 893cc309f5e2
parent 3004 705e34c6fe93
child 3034 793ce2117258
permissions -rw-r--r--
Changed keyboard to show on defined position.

* svghmi.js
added size paramter to edit_value
changed show_modal function to offset keyboard if paramter passed

*widget_input.ysl2
in on_edit_click:
function get position if key_pos element is defined in input widget

*widget_keypad.ysl2
Reworked keypad widget to extand class widget,
added support for changing keyboard position to user defined location
// widget_input.ysl2

template "widget[@type='Input']", mode="widget_defs" {
    param "hmi_element";
    optional_labels("key_pos");
    const "value_elt" {
        optional_labels("value");
    }
    const "have_value","string-length($value_elt)>0";
    value "$value_elt";
    if "$have_value"
    |     frequency: 5,
    |     last_val: undefined,
    |     dispatch: function(value) {
    |         this.last_val = value;
    if "$have_value"
    |         this.value_elt.textContent = String(value);

    |     },
    const "edit_elt_id","$hmi_element/*[@inkscape:label='edit'][1]/@id";
    |     init: function() {
    if "$edit_elt_id" {
    |         id("«$edit_elt_id»").setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_edit_click()");
    }
    foreach "$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-].+')]" {
    |         id("«@id»").setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_op_click('«func:escape_quotes(@inkscape:label)»')");
    }
    |     },
    |     on_op_click: function(opstr) {
    |         let new_val = this.change_hmi_value(0, opstr);
    //     if "$have_value"{
    // |         this.value_elt.textContent = String(new_val);
    //           /* TODO gray out value until refreshed */
    //     }
    |     },
    |     on_edit_click: function(opstr) {
    |         var size = (typeof this.key_pos_elt !== 'undefined') ?  this.key_pos_elt.getBBox() : undefined
    |         edit_value("«path/@value»", "«path/@type»", this, this.last_val,size);
    |     },

    |     edit_callback: function(new_val) {
    |         this.apply_hmi_value(0, new_val);
    //     if "$have_value"{
    // |         this.value_elt.textContent = String(new_val);
    //           /* TODO gray out value until refreshed */
    //     }
    |     },
}