Pyroxenium / Basalt

A UI Framework for CC:Tweaked
MIT License
189 stars 34 forks source link

bug: Setting high ZIndex for parent after adding children overshadows interactions with said children #38

Closed luiz00martins closed 1 year ago

luiz00martins commented 1 year ago

Minimal Working Example

https://user-images.githubusercontent.com/43142209/203252616-efd726ed-06e9-42cb-aadc-66c0ec43a488.mp4

local filePath = "/basalt.lua" --here you can change the file path default: basalt
if not(fs.exists(filePath))then
    shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", "")) -- this is an alternative to the wget command
end
local basalt = require(filePath:gsub(".lua", ""))

local main = basalt.createFrame("mainFrame")

local function visual_button(btn)
    btn:onClick(function(self) btn:setBackground(colors.black) btn:setForeground(colors.lightGray) end)
    btn:onClickUp(function(self) btn:setBackground(colors.gray) btn:setForeground(colors.black) end)
    btn:onLoseFocus(function(self) btn:setBackground(colors.gray) btn:setForeground(colors.black) end)
end

local working_frame = main:addFrame("working_frame")
    :setPosition(2, 2)
    :setSize(20, 10)
    :setBackground(colors.black)
    -- This will work fine (notice that it's done before adding the children).
    :setZIndex(1000)

local working_input = working_frame:addInput("input")
    :setPosition(2, 2)
    :setSize(18, 1)
    :setDefaultText("Search Text")

local working_button = working_frame:addButton("button")
    :setPosition(2, 4)
    :setSize(18, 1)
    :setValue("Search")
visual_button(working_button)

local not_working_frame = main:addFrame("not_working_frame")
    :setPosition(23, 2)
    :setSize(20, 10)
    :setBackground(colors.black)

local not_working_input = not_working_frame:addInput("input")
    :setPosition(2, 2)
    :setSize(18, 1)
    :setDefaultText("Search Text")

local not_working_button = not_working_frame:addButton("button")
    :setPosition(2, 4)
    :setSize(18, 1)
    :setValue("Search")
visual_button(not_working_button)

-- This will effectively disable the children (notice that it's done after adding the children).
not_working_frame:setZIndex(1000)

main:show()
basalt.autoUpdate()

Expected behavior

Children being interactable after changing the ZIndex of parent.

Checklist

[X] I am running the latest version.

NoryiE commented 1 year ago

Hello - thank you for the bug report! The bug got fixed in 37dde88 i guess. Maybe you can also test it. I tested it and the "not_working_frame" works fine after the fix. You need to redownload basalt. The fix got added to the master branch.

Erb3 commented 1 year ago

This should probably be closed. 👍

luiz00martins commented 1 year ago

Yeah, sorry for the delay. Got busy with college, so I left CC hanging for a while.

Just hopped back in though to check, an it seems to be working fine! Thanks for the update