From e8642fbad7761bceba65bf079d5cbd82f2f0da65 Mon Sep 17 00:00:00 2001 From: Hans-Werner Hilse Date: Sun, 30 Nov 2014 22:25:23 +0000 Subject: [PATCH] use API for refresh when closing widgets in message popups --- frontend/ui/widget/infomessage.lua | 15 ++++++++++++--- frontend/ui/widget/notification.lua | 13 +++++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/frontend/ui/widget/infomessage.lua b/frontend/ui/widget/infomessage.lua index f91807ff3..fe17f4cf2 100644 --- a/frontend/ui/widget/infomessage.lua +++ b/frontend/ui/widget/infomessage.lua @@ -25,6 +25,7 @@ local InfoMessage = InputContainer:new{ face = Font:getFace("infofont", 25), text = "", timeout = nil, -- in seconds + closed = false, } function InfoMessage:init() @@ -78,22 +79,30 @@ function InfoMessage:init() } end +function InfoMessage:close() + if not self.closed then + self.closed = true + UIManager:close(self, "partial", self[1][1].dimen) + end +end + function InfoMessage:onShow() -- triggered by the UIManager after we got successfully shown (not yet painted) if self.timeout then - UIManager:scheduleIn(self.timeout, function() UIManager:close(self) end) + UIManager:scheduleIn(self.timeout, function() self:close() end) end + self.closed = false return true end function InfoMessage:onAnyKeyPressed() -- triggered by our defined key events - UIManager:close(self) + self:close() return true end function InfoMessage:onTapClose() - UIManager:close(self) + self:close() return true end diff --git a/frontend/ui/widget/notification.lua b/frontend/ui/widget/notification.lua index 4df000238..9bd2916b6 100644 --- a/frontend/ui/widget/notification.lua +++ b/frontend/ui/widget/notification.lua @@ -20,6 +20,7 @@ local Notification = InputContainer:new{ timeout = nil, margin = 5, padding = 5, + closed = false, } function Notification:init() @@ -55,17 +56,25 @@ function Notification:init() } end +function Notification:close() + if not self.closed then + self.closed = true + UIManager:close(self, "partial", self[1][1].dimen) + end +end + function Notification:onShow() -- triggered by the UIManager after we got successfully shown (not yet painted) if self.timeout then - UIManager:scheduleIn(self.timeout, function() UIManager:close(self) end) + UIManager:scheduleIn(self.timeout, function() self:close() end) end + self.closed = false return true end function Notification:onAnyKeyPressed() -- triggered by our defined key events - UIManager:close(self) + self:close() return true end