From f6d1097ae209ff8c6d4a31b49bfb3ab7c53fb71c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 16 May 2020 15:18:53 +0530 Subject: [PATCH] Fix #1879040 [[Viewer] Right clicking in the Viewer opened without a book closes it](https://bugs.launchpad.net/calibre/+bug/1879040) --- src/pyj/read_book/overlay.pyj | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pyj/read_book/overlay.pyj b/src/pyj/read_book/overlay.pyj index 43df850b06..626099082d 100644 --- a/src/pyj/read_book/overlay.pyj +++ b/src/pyj/read_book/overlay.pyj @@ -486,7 +486,8 @@ class OpenBook: # {{{ if self.closeable: self.overlay.hide_current_panel() else: - ui_operations.quit() + if self.overlay.handling_context_menu_event is None: + ui_operations.quit() def on_container_click(self, evt): pass # Dont allow panel to be closed by a click @@ -516,6 +517,7 @@ class Overlay: def __init__(self, view): self.view = view + self.handling_context_menu_event = None c = self.clear_container() c.addEventListener('click', self.container_clicked) c.addEventListener('contextmenu', self.oncontextmenu, {'passive': False}) @@ -525,7 +527,9 @@ class Overlay: if evt.target and evt.target.tagName and evt.target.tagName.toLowerCase() in ('input', 'textarea'): return evt.preventDefault() + self.handling_context_menu_event = evt self.handle_escape() + self.handling_context_menu_event = None def clear_container(self): c = self.container