Set window values on reload
This commit is contained in:
parent
f47a839341
commit
3a04122e26
@ -16,10 +16,6 @@ local Element = {
|
||||
}
|
||||
Element.__index = Element
|
||||
|
||||
local function createWindow(element)
|
||||
return window.create(element.parent, element:getX(), element:getY(), element:getWidth(), element:getHeight(), element:isVisible())
|
||||
end
|
||||
|
||||
|
||||
function Element:new(o)
|
||||
local obj = o or {}
|
||||
@ -35,6 +31,10 @@ function Element:new(o)
|
||||
end
|
||||
|
||||
function Element:draw()
|
||||
local win = self:_getWindow()
|
||||
-- Calling draw() without a valid window is a logical error
|
||||
---@diagnostic disable-next-line: need-check-nil
|
||||
win.setCursorPos(1, 1)
|
||||
self.dirty = false
|
||||
end
|
||||
|
||||
@ -189,7 +189,10 @@ function Element:setOnClick(onClick)
|
||||
end
|
||||
|
||||
function Element:_reload()
|
||||
self:_setWindow(createWindow(self))
|
||||
local window = window.create(self.parent, self:getX(), self:getY(), self:getWidth(), self:getHeight(), self:isVisible())
|
||||
window.setBackgroundColor(self:getBgColor())
|
||||
window.setTextColor(self:getFgColor())
|
||||
self:_setWindow(window)
|
||||
end
|
||||
|
||||
return Element
|
Loading…
x
Reference in New Issue
Block a user