svghmi/widget_back.ysl2
author Edouard Tisserant
Thu, 11 Aug 2022 12:11:35 +0200
changeset 3579 c5070b6973ba
parent 3241 fe945f1f48b7
child 3653 d5ff60e906b0
permissions -rw-r--r--
SVGHMI: add support for multiline widget declaration using svg:desc.

Declaration started in inkscape:label and interupted by a '\' can be continued in the description field.
After an empty line, the rest of the description field is left for description text.
// widget_back.ysl2

widget_desc("Back") {
    longdesc
    ||
    Back widget brings focus back to previous page in history when clicked.
    ||

    shortdesc > Jump to previous page
}

// TODO: use es6
widget_class("Back")
    ||
        on_click(evt) {
            if(jump_history.length > 1){
               jump_history.pop();
               let [page_name, index] = jump_history.pop();
               switch_page(page_name, index);
            }
        }
        init() {
            this.element.setAttribute("onclick", "hmi_widgets['"+this.element_id+"'].on_click(evt)");
        }
    ||