svghmi/widget_button.ysl2
author Edouard Tisserant
Thu, 14 May 2020 17:48:58 +0200
branchsvghmi
changeset 2968 556ef07a7e31
parent 2961 00825316ed00
child 2976 99c4521bb844
permissions -rw-r--r--
SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
// widget_button.ysl2

template "widget[@type='Button']", mode="widget_class"
    ||
    class ButtonWidget extends Widget{
        frequency = 5;
        init() {
            this.element.addEventListener(
              "mousedown",
              evt => {
                  change_hmi_value(this.indexes[0], "=1");
              });
            this.element.addEventListener(
              "mouseup",
              evt => {
                  change_hmi_value(this.indexes[0], "=0");
              });
        }
    }
    ||