mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[ReaderHighlight] NT: add better support for extending highlights (#13917)
This commit is contained in:
@@ -75,6 +75,9 @@ function ReaderHighlight:init()
|
||||
callback = function()
|
||||
this:startSelection(index)
|
||||
this:onClose()
|
||||
if not Device:isTouchDevice() then
|
||||
self:onStartHighlightIndicator()
|
||||
end
|
||||
end,
|
||||
}
|
||||
end,
|
||||
@@ -2678,6 +2681,13 @@ function ReaderHighlight:onHighlightPress(skip_tap_check)
|
||||
self:onStopHighlightIndicator()
|
||||
return true
|
||||
end
|
||||
-- Check if we're in select mode (or extending an existing highlight)
|
||||
if self.select_mode and self.highlight_idx then
|
||||
self:onHold(nil, self:_createHighlightGesture("hold"))
|
||||
self:onHoldRelease(nil, self:_createHighlightGesture("hold_release"))
|
||||
self:onStopHighlightIndicator()
|
||||
return true
|
||||
end
|
||||
-- Attempt to open an existing highlight
|
||||
if not skip_tap_check and self:onTap(nil, self:_createHighlightGesture("tap")) then
|
||||
self:onStopHighlightIndicator(true) -- need_clear_selection=true
|
||||
@@ -2797,6 +2807,16 @@ function ReaderHighlight:onStartHighlightIndicator()
|
||||
end
|
||||
|
||||
function ReaderHighlight:onStopHighlightIndicator(need_clear_selection)
|
||||
-- If we're in select mode and user presses back, end the selection
|
||||
if self.select_mode and self.highlight_idx then
|
||||
self.select_mode = false
|
||||
if self.ui.annotation.annotations[self.highlight_idx].is_tmp then
|
||||
self:deleteHighlight(self.highlight_idx) -- temporary highlight, delete it
|
||||
else
|
||||
UIManager:setDirty(self.dialog, "ui", self.view.flipping:getRefreshRegion())
|
||||
end
|
||||
self.highlight_idx = nil
|
||||
end
|
||||
if self._current_indicator_pos then
|
||||
local rect = self._current_indicator_pos
|
||||
self._previous_indicator_pos = rect
|
||||
|
||||
Reference in New Issue
Block a user