svghmi/widget_back.ysl2
author Edouard Tisserant
Thu, 23 Dec 2021 11:36:37 +0100
branchRuntimeLists
changeset 3399 95e0b926a8c3
parent 3241 fe945f1f48b7
child 3653 d5ff60e906b0
permissions -rw-r--r--
SVGHMI: optimization of C part : stop traversing the whole HMI tree, use dual linked list for subscriptions and single linked list for changes from HMI. Intermediate commit, still crashing in some cases.
// 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)");
        }
    ||