svghmi/widget_back.ysl2
author Edouard Tisserant
Thu, 17 Nov 2022 11:08:36 +0100
changeset 3682 c613afdab571
parent 3654 6b7f15089703
permissions -rw-r--r--
IDE: Optimization of modification events processing in text editors.

Too many modifications types where registered, and then too many events were fired.
Also, in case of uninterrupted sequence of events, updates to the model is deferred to the end of that sequence (wx.Callafter).
// widget_back.ysl2

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

    shortdesc > Jump to previous page
}

widget_class("Back")
    ||
        on_click(evt) {
            if(jump_history.length > 1){
               let page_name, index;
               do {
                   jump_history.pop(); // forget current page
                   if(jump_history.length == 0) return;
                   [page_name, index] = jump_history[jump_history.length-1];
               } while(page_name == "ScreenSaver") // never go back to ScreenSaver
               switch_page(page_name, index);
            }
        }
        init() {
            this.element.onclick = this.on_click.bind(this);
        }
    ||