Fix #1918054 [[Enhancement - Content server viewer] Clicking Esc to go back in the Highlight page doesn't work if one highlight is selected](https://bugs.launchpad.net/calibre/+bug/1918054)

This commit is contained in:
Kovid Goyal 2021-03-08 20:18:32 +05:30
parent f463c1dd97
commit dc41e4e30e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 10 additions and 5 deletions

View File

@ -808,7 +808,7 @@ def delete_selection(annotations_manager, view):
)
def highlight_entry(h, onclick, view):
def highlight_entry(h, onclick, view, hide_panel):
def action(func, ev):
ev.stopPropagation(), ev.preventDefault()
@ -828,7 +828,12 @@ def highlight_entry(h, onclick, view):
class_='title-row',
E.div(class_='title', swatch, E.div(style='margin-left: 1rem', h.highlighted_text)),
E.div(style='margin-left: 1rem', onclick=def(ev): ev.stopPropagation();,
E.input(type='checkbox', onchange=item_select_toggled)),
E.input(type='checkbox', onchange=item_select_toggled, onkeydown=def(ev):
if ev.key is 'Escape':
ev.stopPropagation()
ev.preventDefault()
hide_panel()
)),
),
E.div(
class_='actions',
@ -847,7 +852,7 @@ def highlight_entry(h, onclick, view):
return ans
def create_highlights_panel(annotations_manager, book, container, onclick):
def create_highlights_panel(annotations_manager, hide_panel, book, container, onclick):
next_button = E.div(class_='simple-link ac-button', svgicon('chevron-down'), title=_('Next match'))
prev_button = E.div(class_='simple-link ac-button', svgicon('chevron-up'), title=_('Previous match'))
prev_button.addEventListener('click', def(ev): find_previous();)
@ -917,5 +922,5 @@ def create_highlights_panel(annotations_manager, book, container, onclick):
c.appendChild(g)
ic = g.lastChild
for h in highlights:
ic.appendChild(highlight_entry(h, onclick, annotations_manager.view))
ic.appendChild(highlight_entry(h, onclick, annotations_manager.view, hide_panel))
# }}}

View File

@ -720,7 +720,7 @@ class Overlay:
self.hide()
ui_operations.toggle_highlights()
return
self.panels.push(TOCOverlay(self, create_highlights_panel.bind(None, self.view.annotations_manager), _('Highlights')))
self.panels.push(TOCOverlay(self, create_highlights_panel.bind(None, self.view.annotations_manager, self.hide_current_panel), _('Highlights')))
self.show_current_panel()
def show_goto(self):