svghmi/widget_customhtml.ysl2
author Edouard Tisserant <edouard.tisserant@gmail.com>
Sun, 02 May 2021 23:01:08 +0200
branchsvghmi
changeset 3232 7bdb766c2a4d
parent 3064 4b44d09c48a7
child 3241 fe945f1f48b7
permissions -rw-r--r--
SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
// widget_customhtml.ysl2

widget_class("CustomHtml"){
    ||
        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>';
        }
    ||
}


widget_defs("CustomHtml") {
    param "hmi_element";
    labels("container code");
}