Cancel any speech in progress when hiding the selection_bar after triggering the speak aloud action on it

This commit is contained in:
Kovid Goyal 2021-01-03 22:29:51 +05:30
parent c92e726850
commit 23f0086ab7
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -650,9 +650,13 @@ class SelectionBar:
# show and hide {{{ # show and hide {{{
def hide(self): def hide(self):
was_shown = self.state is not HIDDEN
self.state = HIDDEN self.state = HIDDEN
self.container.style.display = 'none' self.container.style.display = 'none'
self.view.focus_iframe() 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): def show(self):
sd = get_session_data() sd = get_session_data()
@ -955,6 +959,7 @@ class SelectionBar:
text = self.view.currently_showing.selection.text text = self.view.currently_showing.selection.text
if text: if text:
ui_operations.speak_simple_text(text) ui_operations.speak_simple_text(text)
self.spoken_aloud_at_least_once = True
def create_highlight(self): def create_highlight(self):
cs = self.view.currently_showing.selection cs = self.view.currently_showing.selection