1
0
mirror of https://github.com/kepler155c/opus synced 2025-10-15 07:47:40 +00:00

Event cleanup

This commit is contained in:
kepler155c@gmail.com
2019-02-24 06:58:26 -05:00
parent 8ae3b33374
commit 687fc05445
3 changed files with 18 additions and 46 deletions

View File

@@ -35,8 +35,12 @@ function UI.Notification:success(value, timeout)
end
function UI.Notification:cancel()
if self.timer then
Event.off(self.timer)
self.timer = nil
end
if self.canvas then
Event.cancelNamedTimer('notificationTimer')
self.enabled = false
self.canvas:removeLayer()
self.canvas = nil
@@ -60,7 +64,7 @@ function UI.Notification:display(value, timeout)
self:write(2, k, v)
end
Event.addNamedTimer('notificationTimer', timeout or 3, false, function()
self.timer = Event.onTimeout(timeout or 3, function()
self:cancel()
self:sync()
end)

View File

@@ -62,10 +62,9 @@ function UI.StatusBar:getValue(name)
end
function UI.StatusBar:timedStatus(status, timeout)
timeout = timeout or 3
self:write(2, 1, Util.widthify(status, self.width-2), self.backgroundColor)
Event.addNamedTimer('statusTimer', timeout, false, function()
if self.parent.enabled then
Event.on(timeout or 3, function()
if self.enabled then
self:draw()
self:sync()
end