fix #1682 by closing all dict windows when holding close icon

pull/2114/head
chrox 8 years ago
parent 71bf9efc7c
commit 1c5c7d3a7c

@ -12,6 +12,7 @@ local T = require("ffi/util").template
local ReaderDictionary = InputContainer:new{
data_dir = nil,
dict_window_list = {},
}
function ReaderDictionary:init()
@ -104,6 +105,7 @@ function ReaderDictionary:showDict(word, results, box)
if results and results[1] then
DEBUG("showing quick lookup window", word, results)
self.dict_window = DictQuickLookup:new{
window_list = self.dict_window_list,
ui = self.ui,
highlight = self.highlight,
dialog = self.dialog,
@ -116,6 +118,7 @@ function ReaderDictionary:showDict(word, results, box)
-- differentiate between dict and wiki
wiki = self.wiki,
}
table.insert(self.dict_window_list, self.dict_window)
UIManager:show(self.dict_window)
end
end

@ -52,10 +52,27 @@ function CloseButton:init()
},
doc = "Tap on close button",
}
self.ges_events.HoldClose = {
GestureRange:new{
ges = "hold_release",
range = function() return self.dimen end,
},
doc = "Hold on close button",
}
end
function CloseButton:onClose()
self.window:onClose()
if self.window.onClose then
self.window:onClose()
end
return true
end
function CloseButton:onHoldClose()
if self.window.onHoldClose then
self.window:onHoldClose()
end
return true
end

@ -88,7 +88,7 @@ function DictQuickLookup:init()
-- callback function when HoldWord is handled as args
args = function(word)
self.ui:handleEvent(
Event:new("LookupWord", word, self.word_box))
Event:new("LookupWord", word, self.word_box, self.highlight))
end
},
}
@ -384,8 +384,24 @@ end
function DictQuickLookup:onClose()
UIManager:close(self)
for i = #self.window_list, 1, -1 do
local window = self.window_list[i]
if window == self then
table.remove(self.window_list, i)
end
end
if self.highlight then
self.highlight:handleEvent(Event:new("Tap"))
self.highlight:clear()
end
return true
end
function DictQuickLookup:onHoldClose()
self:onClose()
for i = #self.window_list, 1, -1 do
local window = self.window_list[i]
UIManager:close(window)
table.remove(self.window_list, i)
end
return true
end

Loading…
Cancel
Save