diff --git a/src/pyj/read_book/overlay.pyj b/src/pyj/read_book/overlay.pyj index d2c6debe21..a8f9320447 100644 --- a/src/pyj/read_book/overlay.pyj +++ b/src/pyj/read_book/overlay.pyj @@ -421,7 +421,10 @@ class PrefsOverlay: # {{{ def show(self, container): self.changes_occurred = False container.style.backgroundColor = get_color('window-background') - create_prefs_panel(container, self.overlay.hide_current_panel, def():self.changes_occurred=True;) + self.prefs = create_prefs_panel(container, self.overlay.hide_current_panel, def():self.changes_occurred=True;) + + def handle_escape(self): + self.prefs.onclose() def on_hide(self): if self.changes_occurred: @@ -530,7 +533,10 @@ class Overlay: if self.panels.length: p = self.panels[-1] if not p.is_not_escapable: - self.hide_current_panel() + if p.handle_escape: + p.handle_escape() + else: + self.hide_current_panel() return True return False diff --git a/src/pyj/read_book/prefs/main.pyj b/src/pyj/read_book/prefs/main.pyj index 53806ac07c..516afdf024 100644 --- a/src/pyj/read_book/prefs/main.pyj +++ b/src/pyj/read_book/prefs/main.pyj @@ -140,4 +140,4 @@ class Prefs: def create_prefs_panel(container, close_func, on_change): - Prefs(container, close_func, on_change) + return Prefs(container, close_func, on_change)