From 23f0086ab7afe33f1fcd563e3d7eb7c5b8651312 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 3 Jan 2021 22:29:51 +0530 Subject: [PATCH] Cancel any speech in progress when hiding the selection_bar after triggering the speak aloud action on it --- src/pyj/read_book/selection_bar.pyj | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pyj/read_book/selection_bar.pyj b/src/pyj/read_book/selection_bar.pyj index faa5e92002..86a333115a 100644 --- a/src/pyj/read_book/selection_bar.pyj +++ b/src/pyj/read_book/selection_bar.pyj @@ -650,9 +650,13 @@ class SelectionBar: # show and hide {{{ def hide(self): + was_shown = self.state is not HIDDEN self.state = HIDDEN self.container.style.display = 'none' self.view.focus_iframe() + if not was_shown and self.spoken_aloud_at_least_once: + ui_operations.speak_simple_text('') # cancel any on-going speech + self.spoken_aloud_at_least_once = False def show(self): sd = get_session_data() @@ -955,6 +959,7 @@ class SelectionBar: text = self.view.currently_showing.selection.text if text: ui_operations.speak_simple_text(text) + self.spoken_aloud_at_least_once = True def create_highlight(self): cs = self.view.currently_showing.selection