From e5bf0eb13ee244b1c7bd2c2a6bdf3529387df7e1 Mon Sep 17 00:00:00 2001 From: chrox Date: Fri, 20 Dec 2013 12:05:07 +0800 Subject: [PATCH] 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. --- frontend/ui/reader/readerdictionary.lua | 4 +++- frontend/ui/reader/readerhighlight.lua | 8 ++++---- frontend/ui/widget/dictquicklookup.lua | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/frontend/ui/reader/readerdictionary.lua b/frontend/ui/reader/readerdictionary.lua index 5d9f76add..6388dcd14 100644 --- a/frontend/ui/reader/readerdictionary.lua +++ b/frontend/ui/reader/readerdictionary.lua @@ -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, diff --git a/frontend/ui/reader/readerhighlight.lua b/frontend/ui/reader/readerhighlight.lua index c33d0312e..cdf1d2928 100644 --- a/frontend/ui/reader/readerhighlight.lua +++ b/frontend/ui/reader/readerhighlight.lua @@ -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 diff --git a/frontend/ui/widget/dictquicklookup.lua b/frontend/ui/widget/dictquicklookup.lua index 06442a0aa..056b0f20b 100644 --- a/frontend/ui/widget/dictquicklookup.lua +++ b/frontend/ui/widget/dictquicklookup.lua @@ -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))