mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Viewer: Fix ESC key not working reliably in preference panels
Fixes #1964505 [[Enhancement - Content server] Pressing ESC to close Preferences page and subpages](https://bugs.launchpad.net/calibre/+bug/1964505)
This commit is contained in:
parent
852b9d8cd2
commit
6cfeec7245
@ -30,6 +30,13 @@ class Prefs:
|
|||||||
self.main_title = _('Configure book reader')
|
self.main_title = _('Configure book reader')
|
||||||
container.appendChild(E.div(
|
container.appendChild(E.div(
|
||||||
style='contain: paint; width: 100%; height: 100%; display: flex; flex-direction: column',
|
style='contain: paint; width: 100%; height: 100%; display: flex; flex-direction: column',
|
||||||
|
tabindex='-1',
|
||||||
|
onkeydown=def(ev):
|
||||||
|
if ev.key is 'Escape':
|
||||||
|
ev.stopPropagation(), ev.preventDefault()
|
||||||
|
if not self.cancel():
|
||||||
|
self.close_func()
|
||||||
|
,
|
||||||
E.div(), E.div(style='flex-grow: 100; overflow: auto')
|
E.div(), E.div(style='flex-grow: 100; overflow: auto')
|
||||||
))
|
))
|
||||||
container = container.firstChild
|
container = container.firstChild
|
||||||
@ -48,6 +55,7 @@ class Prefs:
|
|||||||
if self.stack.length > 1:
|
if self.stack.length > 1:
|
||||||
self.stack.pop()
|
self.stack.pop()
|
||||||
self.display_panel(self.stack[-1])
|
self.display_panel(self.stack[-1])
|
||||||
|
return True
|
||||||
|
|
||||||
def onclose(self):
|
def onclose(self):
|
||||||
if self.stack.length > 1:
|
if self.stack.length > 1:
|
||||||
@ -74,6 +82,8 @@ class Prefs:
|
|||||||
container = self.container
|
container = self.container
|
||||||
clear(container)
|
clear(container)
|
||||||
getattr(self, 'display_' + which)(container)
|
getattr(self, 'display_' + which)(container)
|
||||||
|
container.setAttribute('tabindex', '-1')
|
||||||
|
container.focus()
|
||||||
|
|
||||||
def show_panel(self, which):
|
def show_panel(self, which):
|
||||||
self.stack.push(which)
|
self.stack.push(which)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user