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

Add a list dialog element #60

Open
Omar-Abdul-Azeez opened this issue Nov 1, 2021 · 1 comment
Open

Add a list dialog element #60

Omar-Abdul-Azeez opened this issue Nov 1, 2021 · 1 comment

Comments

@Omar-Abdul-Azeez
Copy link

Omar-Abdul-Azeez commented Nov 1, 2021

this is basically what it should look like... (this is the environment variables list in windows)

image

it's essentially a combobox but instead of a dropdown it has a fixed width (just a number) and height in terms of number of entries that should fit before getting a scrollbar.
any extra entries should give it a scrollbar and the entries should be selectable using the mouse and navigable using arrow keys
ideally double clicking an entry should call an onclick function which is passed the double clicked string but it's ok if not possible since it can be replicated using a button

@Kaiqgs
Copy link

Kaiqgs commented Jan 8, 2022

I think you can achieve a similar behavior by making an array of entries, then identify which is being selected by its "onchange" callback.

local listwidget = {"C:\\foo", "C:\\bar", "C:\\bazar"}
local function onlistchange(index, lineid)
    --This will update every character change;
    app.alert("List index="..index.." changed to = ".. dialog.data[lineid])
end

local function setlist(index, value) dialog:modify{id=listwidget[index], text=value} end

for i,dir in ipairs(listwidget) do
    -- You don't have to use same id&Text;
    dialog:entry{id=dir, text=dir, onchange=function ()
        onlistchange(i, dir)
    end}
    -- To not share same row, and achieve column like struct;
    dialog:newrow()
end

Finally you could delete a line by dialog:modify{id=id, visible=false}. Logic of new line insertion stays the same as in the example above. Sorting items around would be harder but doable.
I don't think we'll see an actual list widget on aseprite soon, due to it being more directed towards bureaucratic processes.

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

No branches or pull requests

2 participants