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)

This commit is contained in:
Kovid Goyal 2021-04-25 13:54:13 +05:30
parent edcfcd9792
commit 0dc1dac0b9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 1 deletions

View File

@ -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

View File

@ -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: