svghmi/widget_customhtml.ysl2
author Edouard Tisserant <edouard.tisserant@gmail.com>
Sun, 14 Feb 2021 05:22:30 +0100
branchsvghmi
changeset 3139 1f5ca646ce6e
parent 3064 4b44d09c48a7
child 3232 7bdb766c2a4d
permissions -rw-r--r--
SVGHMI: Add inhibition to widget's apply_hmi_value() so that it does not change variable more frquently than given widget's frequency. This prevents flooding network with many update if browser is producing events at high rate, as for exemple when dragging ScrollBar's cursor.
// widget_customhtml.ysl2

template "widget[@type='CustomHtml']", mode="widget_class"{
    ||
    class CustomHtmlWidget extends Widget{
        frequency = 5;
        widget_size = undefined;

        dispatch(value) {
            this.request_animate();
        }

        animate(){
        }

        init() {
            this.widget_size = this.container_elt.getBBox();
            this.element.innerHTML ='<foreignObject x="'+
                this.widget_size.x+'" y="'+this.widget_size.y+
                '" width="'+this.widget_size.width+'" height="'+this.widget_size.height+'"> '+
                this.code_elt.textContent+
                ' </foreignObject>';
        }
    }
    ||
}


template "widget[@type='CustomHtml']", mode="widget_defs" {
    param "hmi_element";
    labels("container code");
    |,
}