Fixed :removeChild()
This commit is contained in:
Robert Jelic
2024-04-16 19:02:54 +02:00
parent 599edf55dd
commit f3eb0accf8
2 changed files with 8 additions and 7 deletions

View File

@@ -36,9 +36,6 @@ return function(name, basalt)
end end
local function getChild(self, name) local function getChild(self, name)
if (type(name)=="table") then
name = name:getName()
end
for _, v in ipairs(children) do for _, v in ipairs(children) do
if v.element:getName() == name then if v.element:getName() == name then
return v.element return v.element
@@ -47,7 +44,7 @@ return function(name, basalt)
end end
local function getDeepChild(self, name) local function getDeepChild(self, name)
local maybeChild = getChild(name) local maybeChild = self:getChild(name)
if (maybeChild ~= nil) then if (maybeChild ~= nil) then
return maybeChild return maybeChild
end end
@@ -87,7 +84,7 @@ return function(name, basalt)
local function removeChild(self, element) local function removeChild(self, element)
if (type(element)=="string") then if (type(element)=="string") then
element = getChild(element:getName()) element = self:getChild(element)
end end
if (element==nil) then if (element==nil) then
return return
@@ -95,11 +92,13 @@ return function(name, basalt)
for i, v in ipairs(children) do for i, v in ipairs(children) do
if v.element:getName() == element:getName() then if v.element:getName() == element:getName() then
table.remove(children, i) table.remove(children, i)
self:removeEvents(element)
sorted = false
self:updateDraw()
return true return true
end end
end end
self:removeEvents(element) return false
sorted = false
end end
local function removeChildren(self) local function removeChildren(self)

View File

@@ -147,6 +147,8 @@ return function(name, basalt)
loadImage = function(self, path) loadImage = function(self, path)
if(fs.exists(path))then if(fs.exists(path))then
local newBimg = images.loadBIMG(path) local newBimg = images.loadBIMG(path)
print(newBimg[1][1])
sleep(1)
bimgLibrary = bimg(newBimg) bimgLibrary = bimg(newBimg)
activeFrame = 1 activeFrame = 1
bimgFrame = bimgLibrary.getFrameObject(1) bimgFrame = bimgLibrary.getFrameObject(1)