mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
fix closing dict window will bookmark current page
use `self.highlight:handleEvent(Event:new("Tap"))` instead of
`self.ui:handleEvent(Event:new("Tap"))` when clearing highlighted
text since Tap event in latter situation will be captured by
the dogear widget.
This commit is contained in:
@@ -7,7 +7,8 @@ local DEBUG = require("dbg")
|
||||
|
||||
local ReaderDictionary = EventListener:new{}
|
||||
|
||||
function ReaderDictionary:onLookupWord(word)
|
||||
function ReaderDictionary:onLookupWord(highlight, word)
|
||||
self.highlight = highlight
|
||||
self:stardictLookup(word)
|
||||
end
|
||||
|
||||
@@ -36,6 +37,7 @@ function ReaderDictionary:showDict(results)
|
||||
DEBUG("showing quick lookup dictionary window")
|
||||
UIManager:show(DictQuickLookup:new{
|
||||
ui = self.ui,
|
||||
highlight = self.highlight,
|
||||
dialog = self.dialog,
|
||||
results = results,
|
||||
dictionary = self.default_dictionary,
|
||||
|
||||
@@ -225,23 +225,23 @@ end
|
||||
function ReaderHighlight:lookup(selected_word)
|
||||
-- if we extracted text directly
|
||||
if selected_word.word then
|
||||
self.ui:handleEvent(Event:new("LookupWord", selected_word.word))
|
||||
self.ui:handleEvent(Event:new("LookupWord", self, selected_word.word))
|
||||
-- or we will do OCR
|
||||
else
|
||||
local word = self.ui.document:getOCRWord(self.hold_pos.page, selected_word)
|
||||
DEBUG("OCRed word:", word)
|
||||
self.ui:handleEvent(Event:new("LookupWord", word))
|
||||
self.ui:handleEvent(Event:new("LookupWord", self, word))
|
||||
end
|
||||
end
|
||||
|
||||
function ReaderHighlight:translate(selected_text)
|
||||
if selected_text.text ~= "" then
|
||||
self.ui:handleEvent(Event:new("TranslateText", selected_text.text))
|
||||
self.ui:handleEvent(Event:new("TranslateText", self, selected_text.text))
|
||||
-- or we will do OCR
|
||||
else
|
||||
local text = self.ui.document:getOCRText(self.hold_pos.page, selected_text)
|
||||
DEBUG("OCRed text:", text)
|
||||
self.ui:handleEvent(Event:new("TranslateText", text))
|
||||
self.ui:handleEvent(Event:new("TranslateText", self, text))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -268,7 +268,7 @@ end
|
||||
function DictQuickLookup:onTapCloseDict(arg, ges_ev)
|
||||
if ges_ev.pos:notIntersectWith(self.dict_frame.dimen) then
|
||||
UIManager:close(self)
|
||||
self.ui:handleEvent(Event:new("Tap"))
|
||||
self.highlight:handleEvent(Event:new("Tap"))
|
||||
return true
|
||||
elseif not ges_ev.pos:notIntersectWith(self.dict_title.dimen) then
|
||||
self.ui:handleEvent(Event:new("UpdateDefaultDict", self.dictionary))
|
||||
|
||||
Reference in New Issue
Block a user