1ForeverHD / TopbarPlus

Construct dynamic and intuitive topbar icons. Enhance the appearance and behaviour of these icons with features such as themes, dropdowns and menus.
https://devforum.roblox.com/t/topbarplus/1017485
Mozilla Public License 2.0
107 stars 140 forks source link

Have descendant dropdown/menu icons destroyed instead of reparented #33

Closed 1ForeverHD closed 9 months ago

1ForeverHD commented 3 years ago
function Icon:destroy()
    if self._destroyed then return end
    IconController.iconRemoved:Fire(self)
    self:clearNotices()
    if self._parentIcon then
        self:leave()
    end
    local function destroyDescendantIcons(parentIconToCheck)
        local storageNames = {"dropdownIcons", "menuIcons"}
        for _, storageName in pairs(storageNames) do
            for _, childIcon in pairs(parentIconToCheck[storageName]) do
                destroyDescendantIcons(childIcon)
                childIcon:destroy()
            end
        end
    end
    destroyDescendantIcons(self)
    self._destroyed = true
    self._maid:clean()
end

image