svghmi/widget_back.ysl2
author Edouard Tisserant
Mon, 08 Nov 2021 14:06:29 +0100
changeset 3385 18621ce81f5f
parent 3241 fe945f1f48b7
child 3653 d5ff60e906b0
permissions -rw-r--r--
SVGHMI: Changes /CURRENT_PAGE_* behaviour to prevent problem whith multiclient : all clients were switching page when one was jumping.
- now PLC have to prefix page name with "!" to order page switch.
- HMI do not prefix with "!" when jumping, this avoiding looping incidently
- In case of multiple client:
CURRENT_PAGE reflects current page of last client hwo did jump
Setting CURRENT_PAGE with "!" affects all clients simultaneously
// 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)");
        }
    ||