Fix #1921572 [[Viewer] Ctrl+A doesn't work when some text is selected](https://bugs.launchpad.net/calibre/+bug/1921572)

This commit is contained in:
Kovid Goyal 2021-03-27 16:10:56 +05:30
parent 57302df132
commit 9673e288be
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 20 additions and 5 deletions

View File

@ -185,6 +185,12 @@ class IframeBoss:
def modify_selection(self, data):
sel = window.getSelection()
if data.granularity is 'all':
r = document.createRange()
r.selectNode(document.body)
sel.removeAllRanges()
sel.addRange(r)
else:
try:
sel.modify('extend', data.direction, data.granularity)
except:

View File

@ -581,6 +581,7 @@ class SelectionBar:
forwarded = {
'toggle_highlights': True,
'edit_book': True,
'select_all': True,
}
if sc_name is 'show_chrome':
self.clear_selection()

View File

@ -344,6 +344,12 @@ def common_shortcuts(): # {{{
_('Alter the current selection forward by a line'),
),
'select_all': desc(
v'["Ctrl+a"]',
'ui',
_('Select all')
),
'shrink_selection_by_line': desc(
v"['Shift+ArrowUp']",
'ui',

View File

@ -559,6 +559,8 @@ class View:
ui_operations.edit_book(current_spine_item(), self.current_file_progress_frac, self.currently_showing?.selection?.text)
elif data.name is 'goto_location':
self.overlay.show_ask_for_location()
elif data.name is 'select_all':
self.iframe_wrapper.send_message('modify_selection', granularity='all')
elif data.name.startsWith('shrink_selection_by_'):
self.iframe_wrapper.send_message('modify_selection', direction='backward', granularity=data.name.rpartition('_')[-1])
elif data.name.startsWith('extend_selection_by_'):