From 0dc1dac0b970377cb363ee3e716b1bbcec0f6d59 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 25 Apr 2021 13:54:13 +0530 Subject: [PATCH] E-book viewer: Right clicking when text is selected should extend the selection instead of doing nothing. Fixes #1925390 [[Enhancement - Viewer] Right-clicking to deselect text](https://bugs.launchpad.net/calibre/+bug/1925390) --- manual/viewer.rst | 2 +- src/pyj/read_book/selection_bar.pyj | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/manual/viewer.rst b/manual/viewer.rst index f0714778ab..ab7f25c315 100644 --- a/manual/viewer.rst +++ b/manual/viewer.rst @@ -111,7 +111,7 @@ highlight. You can add notes and change the color of the highlight. On a touch screen, long tap a word to select it and show the popup bar. Once in highlight mode you can change what text is selected, using touch screen friendly selection handles. Drag the handles to the top or bottom margins to scroll while selecting. -You can also hold the :kbd:`Shift` key and click to extend the selection, +You can also :kbd:`Shift+click` or :kbd:`right click` to extend the selection, particularly useful for multi-page selections. You can use the :guilabel:`Highlights` button in the viewer diff --git a/src/pyj/read_book/selection_bar.pyj b/src/pyj/read_book/selection_bar.pyj index a850404dde..3f2b42115f 100644 --- a/src/pyj/read_book/selection_bar.pyj +++ b/src/pyj/read_book/selection_bar.pyj @@ -245,6 +245,7 @@ class SelectionBar: container = self.container container.style.overflow = 'hidden' container.addEventListener('click', self.container_clicked, {'passive': False}) + container.addEventListener('contextmenu', self.container_context_menu_requested, {'passive': False}) container.addEventListener('mouseup', self.mouseup_on_container, {'passive': False}) container.addEventListener('mousemove', self.mousemove_on_container, {'passive': False}) container.addEventListener('touchmove', self.touchmove_on_container, {'passive': False}) @@ -475,6 +476,11 @@ class SelectionBar: self.position_in_handle.x = Math.round(ev.clientX - r.left) self.position_in_handle.y = Math.round(ev.clientY - r.top) + def container_context_menu_requested(self, ev): + pos = {'x': ev.clientX, 'y': ev.clientY} + map_to_iframe_coords(pos, get_margins()) + self.send_message('extend-to-point', pos=pos) + def container_clicked(self, ev): ev.stopPropagation(), ev.preventDefault() if self.state is EDITING: