diff --git a/frontend/apps/reader/modules/readerkeyselection.lua b/frontend/apps/reader/modules/readerkeyselection.lua index 18368c637..275056637 100644 --- a/frontend/apps/reader/modules/readerkeyselection.lua +++ b/frontend/apps/reader/modules/readerkeyselection.lua @@ -225,6 +225,10 @@ function ReaderKeySelection:onStartOrMoveHighlightIndicator(args) return true end +function ReaderKeySelection:isActive() + return self._current_indicator_pos ~= nil +end + function ReaderKeySelection:startHighlightIndicator() -- disable long-press icon (poke-ball), as it is triggered constantly due to NT devices needing a workaround for text selection to work. self.ui.highlight.long_hold_reached_action = function() end @@ -406,6 +410,27 @@ function ReaderKeySelection:moveHighlightIndicator(args) return true end +function ReaderKeySelection:pageTurnDuringSelection() + self._edge_dx, self._edge_dy = nil, nil + self._previous_indicator_word = nil + local last_pos = self._current_indicator_pos + local target_x = last_pos.x + last_pos.w * 0.5 + local target_y = last_pos.y + last_pos.h * 0.5 + + local new_word = self:_getNearestWordFromScreenPoint(target_x, target_y) + if new_word then + self:_setIndicatorToWord(new_word) + if not self.ui.highlight.select_mode and self._start_indicator_highlight then + self.ui.highlight:startSelection() + -- we don't want to HoldPan during moveHighlightIndicator, a following Press + -- key should close the startSelection loop though. + self._start_indicator_highlight = nil -- breaks the `if moved and self._ then` + end + else + self:stopHighlightIndicator(true) + end +end + function ReaderKeySelection:_isSingleWord(word) if not word or not word.word then return false end local trimmed_word = word.word:match("^%s*(.-)%s*$") or word.word diff --git a/frontend/apps/reader/modules/readerrolling.lua b/frontend/apps/reader/modules/readerrolling.lua index 0f9b36fb8..20ecaf30e 100644 --- a/frontend/apps/reader/modules/readerrolling.lua +++ b/frontend/apps/reader/modules/readerrolling.lua @@ -944,6 +944,9 @@ function ReaderRolling:onGotoViewRel(diff) if self.ui.document ~= nil then self.xpointer = self.ui.document:getXPointer() end + if self.ui.keyselection:isActive() then + self.ui.keyselection:pageTurnDuringSelection() + end return true end