From d9931464807108059f34cf0b1ed5160a0853323a Mon Sep 17 00:00:00 2001 From: David <97603719+Commodore64user@users.noreply.github.com> Date: Sat, 21 Jun 2025 10:37:01 +0100 Subject: [PATCH] [ReaderHighlight] NT: add better support for extending highlights (#13917) --- .../apps/reader/modules/readerhighlight.lua | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/frontend/apps/reader/modules/readerhighlight.lua b/frontend/apps/reader/modules/readerhighlight.lua index af8d9cef8..ea4059870 100644 --- a/frontend/apps/reader/modules/readerhighlight.lua +++ b/frontend/apps/reader/modules/readerhighlight.lua @@ -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