Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: prioritize active dropdown boxes if they are in the same Z-Index #49

Open
luiz00martins opened this issue Mar 25, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@luiz00martins
Copy link

luiz00martins commented Mar 25, 2023

Problem

Currently, if you have multiple dropdowns in a frame, they are prioritized in the order they were added (last in the top).

This means that if you are adding a bunch of dropdowns in a column (perhaps using a for loop), the dropdown box of the ones above will be overshadowed by the label of the ones below.

Minimal Working Example

-- Basalt configurated installer
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")

for i = 1, 3 do
	local fg_color, bg_color
	if i % 2 == 0 then
		fg_color = colors.black
		bg_color = colors.white
	else
		fg_color = colors.white
		bg_color = colors.black
	end

	main:addDropdown('dropdown_'..i)
		:setPosition(20, 6 + (2*i))
		:setSize(10, 1)
		:addItem('Option 1')
		:addItem('Option 2')
		:addItem('Option 3')
		:addItem('Option 4')
		:addItem('Option 5')
		:setForeground(fg_color)
		:setBackground(bg_color)
		:selectItem(1)
end

basalt.autoUpdate()
output.mp4

Desired Solution

For me, a reasonable solution would be to prioritize rendering the dropdown box over the dropdown label whenever they are in the same index.

Alternative Solutions

From basalt's part:

  • Reverse the priority order (i.e. make later added items less prioritized).
    • I wouldn't like this solution, as I would expect items added later to be rendered above items added beforehand, including dropdowns.
  • Prioritize rendering active dropdowns.
    • I wouldn't like this solution, as I wouldn't expect a dropdown to be "brought to the front" just because it was clicked. For example, in the setup below, the dropdown stays behind after being clicked. That's the behaviour I would expect, and the dropdown getting "popped" up would be weird in that scenario.
output.mp4

From my part:

  • Reversing the for loop. (i.e. for i = 3, 1, -1 do)
  • Manually setting the index. (i.e. :setZIndex(3 - i))
    Both of these workarounds resolve the issue.
output.mp4

Additional context

Although the workarounds (from my part) are quite simple, I think it's reasonable for a developer using the API to assume the dropdowns boxes (on the same level) would be prioritized over labels.

As an example, in the Windows API for GUI, it's true (and expected) that if you add a couple of dropdowns in a column one after another, when you click on the first dropdown, its box won't be overshadowed by the dropdowns below it. I think it's reasonable to assume the same behaviour in basalt.


Edit: I now realize this is probably a bug report, not a feature request... oh well ¯\_(ツ)_/¯

@luiz00martins luiz00martins added the enhancement New feature or request label Mar 25, 2023
@NoryiE
Copy link
Collaborator

NoryiE commented Mar 25, 2023

Hello, thank you - this is a very good idea and i will try to implement it! But i will need a couple of days, especially because currently is a interesting beta to test! :P

@Damianu
Copy link
Contributor

Damianu commented May 7, 2023

It's working now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants