svghmi/widget_back.ysl2
author Edouard Tisserant <edouard.tisserant@gmail.com>
Fri, 11 Mar 2022 14:43:37 +0100
branchwxPython4
changeset 3438 24fbd4d1fe80
parent 3241 fe945f1f48b7
child 3653 d5ff60e906b0
permissions -rw-r--r--
Tests: Re-introduced pytest based tests. Fixed them a bit, commented-out otherwise. Application tests only runs with logging test, and PLCOpenEditor tests seem broken.
// 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)");
        }
    ||