cre.getWordFromPosition(): fix a few issues

Drop the use of crengine's getWordFromPosition() which
is a bit unreliable: it may returns wrong coordinates,
or words from far away in the book (ie. when holding
in the margins).
Rely only on the robust getTextFromPositions() that
we already use for multi words selection.
Having good coordinates allows refreshing a smaller region
(the higlighted word, or the 2 lines if hyphenated).
This commit is contained in:
poire-z
2020-12-22 18:45:27 +01:00
parent d560f9011d
commit dd74194e0a
2 changed files with 76 additions and 22 deletions

View File

@@ -760,10 +760,10 @@ function ReaderHighlight:onHold(arg, ges)
table.insert(boxes, self.selected_word.sbox)
self.view.highlight.temp[self.hold_pos.page] = boxes
end
UIManager:setDirty(self.dialog, "ui")
--- @todo only mark word?
-- Unfortunately, CREngine does not return good coordinates
-- UIManager:setDirty(self.dialog, "partial", self.selected_word.sbox)
-- UIManager:setDirty(self.dialog, "ui")
-- But now it does:
UIManager:setDirty(self.dialog, "ui", self.selected_word.sbox)
self:_resetHoldTimer()
if word.pos0 then
-- Remember original highlight start position, so we can show