Ensure iframe is focused after controls help is shown

This commit is contained in:
Kovid Goyal 2019-08-19 10:00:12 +05:30
parent 102be318d8
commit b480086d00
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 10 additions and 1 deletions

View File

@ -80,4 +80,5 @@ ui_operations = {
'update_font_size': None,
'goto_bookpos': None,
'delete_book': None,
'focus_iframe': None,
}

View File

@ -67,6 +67,7 @@ class ReadUI:
ui_operations.update_font_size = self.update_font_size.bind(self)
ui_operations.goto_bookpos = self.goto_bookpos.bind(self)
ui_operations.delete_book = self.delete_book.bind(self)
ui_operations.focus_iframe = self.focus_iframe.bind(self)
def on_resize(self):
self.view.on_resize()
@ -162,6 +163,9 @@ class ReadUI:
def delete_book(self, book, proceed):
self.db.delete_book(book, proceed)
def focus_iframe(self):
self.view.focus_iframe()
def update_color_scheme(self):
self.view.update_color_scheme()

View File

@ -47,7 +47,8 @@ def show_controls_help():
if not show_controls_help.listener_added:
show_controls_help.listener_added = True
container.addEventListener('click', def():
document.getElementById('controls-help-overlay').style.display = 'none'
document.getElementById('controls-help-overlay').style.display = 'none'
ui_operations.focus_iframe()
)
def msg(txt):
return set_css(E.div(txt), padding='1ex 1em', text_align='center', margin='auto')

View File

@ -251,6 +251,8 @@ if window is window.top:
view.update_color_scheme()
ui_operations.update_font_size = def():
view.update_font_size()
ui_operations.focus_iframe = def():
view.focus_iframe()
ui_operations.goto_bookpos = def(cfi):
return view.goto_bookpos(cfi)
ui_operations.toggle_toc = def():
@ -267,6 +269,7 @@ if window is window.top:
to_python.report_cfi(request_id, data)
ui_operations.ask_for_open = def(path):
to_python.ask_for_open(path)
document.body.appendChild(E.div(id='view'))
window.onerror = onerror
create_modal_container()