diff --git a/src/pyj/read_book/hints.pyj b/src/pyj/read_book/hints.pyj index 7046ba5007..366ace09af 100644 --- a/src/pyj/read_book/hints.pyj +++ b/src/pyj/read_book/hints.pyj @@ -12,6 +12,11 @@ class Hints: container.style.overflow = 'hidden' container.addEventListener('keydown', self.on_keydown, {'passive': False}) container.addEventListener('click', self.container_clicked, {'passive': False}) + self.reset() + + def reset(self): + self.hints_map = {} + self.current_prefix = '' @property def container(self): @@ -28,9 +33,11 @@ class Hints: if self.is_visible: self.container.style.display = 'none' self.send_message('hide') + self.reset() def show(self): if not self.is_visible: + self.reset() self.container.style.display = 'block' self.focus() self.send_message('show') @@ -47,6 +54,7 @@ class Hints: def handle_message(self, msg): if msg.type is 'shown': + self.reset() self.hints_map = msg.hints_map @@ -66,7 +74,7 @@ def hint_visible_links(link_attr): h = i + '' a.setAttribute('calibre-hint-render', i.toString(36)) a.setAttribute('calibre-hint-value', h) - hint_map[h] = a.getAttribute(link_attr) + hint_map[h] = {'type': 'link', 'data':a.getAttribute(link_attr)} a.classList.add('calibre-hint-visible') return hint_map diff --git a/src/pyj/read_book/view.pyj b/src/pyj/read_book/view.pyj index b3bca5db5e..51323ebdf9 100644 --- a/src/pyj/read_book/view.pyj +++ b/src/pyj/read_book/view.pyj @@ -297,6 +297,7 @@ class View: , 'annotations': self.on_annotations_message, 'tts': self.on_tts_message, + 'hints': self.on_hints_message, 'copy_text_to_clipboard': def(data): ui_operations.copy_selection(data.text, data.html) ,