diff --git a/src/pyj/read_book/overlay.pyj b/src/pyj/read_book/overlay.pyj index 28e92f3073..d6534e1e1a 100644 --- a/src/pyj/read_book/overlay.pyj +++ b/src/pyj/read_book/overlay.pyj @@ -425,7 +425,10 @@ class PrefsOverlay: # {{{ def show(self, container): self.changes_occurred = False container.style.backgroundColor = get_color('window-background') - self.prefs = 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, self.on_change) + + def on_change(self): + self.changes_occurred = True def handle_escape(self): self.prefs.onclose() diff --git a/src/pyj/read_book/prefs/keyboard.pyj b/src/pyj/read_book/prefs/keyboard.pyj index c9a52a4c5a..12256fc95e 100644 --- a/src/pyj/read_book/prefs/keyboard.pyj +++ b/src/pyj/read_book/prefs/keyboard.pyj @@ -145,7 +145,7 @@ def customize_shortcut(sc_name): -def create_keyboard_panel(container, close_func, onchange): +def create_keyboard_panel(container, apply_func, cancel_func, onchange): create_keyboard_panel.onchange = onchange container.appendChild(E.div(id=unique_id('keyboard-settings'), style='margin: 1rem')) container = container.lastChild @@ -168,7 +168,7 @@ def create_keyboard_panel(container, close_func, onchange): create_item_list(container.lastChild, items) container.appendChild(E.div( - style='margin-top: 1rem', create_button(_('Restore defaults'), action=restore_defaults.bind(None, close_func)) + style='margin-top: 1rem', create_button(_('Restore defaults'), action=restore_defaults.bind(None, apply_func)) )) diff --git a/src/pyj/read_book/prefs/main.pyj b/src/pyj/read_book/prefs/main.pyj index fb6f3e9ab3..2e14651fc3 100644 --- a/src/pyj/read_book/prefs/main.pyj +++ b/src/pyj/read_book/prefs/main.pyj @@ -55,9 +55,12 @@ class Prefs: else: self.close_func() - def create_panel(self, container, which, create_func): + def create_panel(self, container, which, create_func, needs_onchange): document.getElementById(self.title_id).textContent = self.title_map[which] or which - create_func(container, self.onclose, self.cancel) + if needs_onchange: + create_func(container, self.onclose, self.cancel, self.onchange) + else: + create_func(container, self.onclose, self.cancel) @property def container(self): @@ -131,7 +134,7 @@ class Prefs: commit_head_foot(self.onchange, self.container) def display_keyboard(self, container): - self.create_panel(container, 'keyboard', create_keyboard_panel) + self.create_panel(container, 'keyboard', create_keyboard_panel, True) def close_keyboard(self): commit_keyboard(self.onchange, self.container)