From 3a04122e2669c1e18c5f4bf13a80d4537665a150 Mon Sep 17 00:00:00 2001 From: Gabriel Tofvesson Date: Wed, 2 Oct 2024 13:54:08 +0200 Subject: [PATCH] Set window values on reload --- gfx/element.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gfx/element.lua b/gfx/element.lua index b5af444..ab73a7d 100644 --- a/gfx/element.lua +++ b/gfx/element.lua @@ -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 \ No newline at end of file