diff --git a/src/pyj/read_book/prefs/keyboard.pyj b/src/pyj/read_book/prefs/keyboard.pyj index 6012f217c5..438078c624 100644 --- a/src/pyj/read_book/prefs/keyboard.pyj +++ b/src/pyj/read_book/prefs/keyboard.pyj @@ -83,6 +83,7 @@ def close_customize_shortcut(apply_changes): item.dataset.userData = JSON.stringify(q) break get_container().dataset.changed = 'true' + commit_keyboard(create_keyboard_panel.onchange) def add_key_widget(): @@ -143,7 +144,8 @@ def customize_shortcut(sc_name): -def create_keyboard_panel(container, close_func): +def create_keyboard_panel(container, close_func, onchange): + create_keyboard_panel.onchange = onchange container.appendChild(E.div(id=unique_id('keyboard-settings'), style='margin: 1rem')) container = container.lastChild container.dataset.changed = 'false' @@ -189,5 +191,6 @@ def commit_keyboard(onchange): if shortcuts_differ(q.shortcuts, SHORTCUTS[q.name].shortcuts): vals[q.name] = q.shortcuts sd.set('keyboard_shortcuts', vals) + create_keyboard_panel.onchange = None if get_container().dataset.changed is 'true': onchange() diff --git a/src/pyj/read_book/prefs/main.pyj b/src/pyj/read_book/prefs/main.pyj index b9b2e4cb4d..30d40df08d 100644 --- a/src/pyj/read_book/prefs/main.pyj +++ b/src/pyj/read_book/prefs/main.pyj @@ -124,7 +124,7 @@ class Prefs: def display_keyboard(self, container): document.getElementById(self.title_id).textContent = _('Keyboard shortcuts') - create_keyboard_panel(container, self.onclose) + create_keyboard_panel(container, self.onclose, self.onchange) def close_keyboard(self): commit_keyboard(self.onchange, self.container)