mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#84 recursive get element by id
This commit is contained in:
parent
f1a50990f2
commit
f4f36b020b
@ -187,8 +187,20 @@ function element.new(args)
|
||||
---@param key string|integer
|
||||
function public.remove(key) self.children[key] = nil end
|
||||
|
||||
-- attempt to get a child element by ID (does not include this element itself)
|
||||
---@param id element_id
|
||||
---@return graphics_element|nil element
|
||||
function public.get_element_by_id(id)
|
||||
if self.children[id] == nil then
|
||||
for _, child in pairs(self.children) do
|
||||
local elem = child.get_element_by_id(id)
|
||||
if elem ~= nil then return elem end
|
||||
end
|
||||
else
|
||||
return self.children[id]
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
-- get the foreground/background colors
|
||||
|
Loading…
Reference in New Issue
Block a user