From affe2d6c6dffa31855c7942e16984c5b7474b869 Mon Sep 17 00:00:00 2001 From: Mikayla Date: Fri, 16 Aug 2024 21:17:36 +0000 Subject: [PATCH] listbox debugging --- graphics/element.lua | 4 ++++ graphics/elements/listbox.lua | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/graphics/element.lua b/graphics/element.lua index 7475dc1..8de720a 100644 --- a/graphics/element.lua +++ b/graphics/element.lua @@ -3,6 +3,7 @@ -- local util = require("scada-common.util") +local log = require("scada-common.log") local core = require("graphics.core") @@ -503,7 +504,10 @@ function element.new(args, constraint, child_offset_x, child_offset_y) if args.parent ~= nil then -- remove self from parent + log.debug("removing " .. self.id .. " from parent") args.parent.__remove_child(self.id) + else + log.debug("no parent for " .. self.id .. " on delete attempt") end end diff --git a/graphics/elements/listbox.lua b/graphics/elements/listbox.lua index 3da9ac6..409b6db 100644 --- a/graphics/elements/listbox.lua +++ b/graphics/elements/listbox.lua @@ -1,6 +1,7 @@ -- Scroll-able List Box Display Graphics Element local tcd = require("scada-common.tcd") +local log = require("scada-common.log") local core = require("graphics.core") local element = require("graphics.element") @@ -152,6 +153,7 @@ local function listbox(args) next_y = next_y + item.h + item_pad item.e.reposition(1, item.y) item.e.show() + log.debug("iterated " .. item.e.get_id()) end content_height = next_y @@ -210,6 +212,7 @@ local function listbox(args) ---@param child graphics_element child element function e.on_added(id, child) table.insert(list, { id = id, e = child, y = 0, h = child.get_height() }) + log.debug("added child " .. id .. " into slot " .. #list) update_positions() end @@ -219,10 +222,12 @@ local function listbox(args) for idx, elem in ipairs(list) do if elem.id == id then table.remove(list, idx) + log.debug("removed child " .. id .. " from slot " .. idx) update_positions() return end end + log.debug("failed to remove child " .. id) end -- handle focus