Dict, Trapper: prevent dismissal by past events

Add UIManager:discardEvents(), to allow dropping events
for a period of time.
Default duration of 600ms on eInk, 300ms otherwise.
Used when showing the dict result window, so that a tap
happening just when it's being shown won't discard it.
Used with Trapper:confirm()/:info(), to avoid taps made
in a previous processing to dismiss (and so, select the
cancel action) a ConfirmBox not yet painted/visible.
This commit is contained in:
poire-z
2021-01-01 14:34:55 +01:00
parent b6323f15fc
commit 6205f26047
5 changed files with 67 additions and 9 deletions

View File

@@ -889,6 +889,12 @@ function ReaderDictionary:showDict(word, results, box, link)
self:dismissLookupInfo()
if results and results[1] then
UIManager:show(self.dict_window)
if not results[1].lookup_cancelled then
-- Discard queued and coming up events to avoid accidental
-- dismissal (but not if lookup interrupted, so 2 quick
-- taps can discard everything)
UIManager:discardEvents(true)
end
end
end