api icon indicating copy to clipboard operation
api copied to clipboard

Add a list dialog element

Open Omar-Abdul-Azeez opened this issue 4 years ago • 1 comments

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

Omar-Abdul-Azeez avatar Nov 01 '21 19:11 Omar-Abdul-Azeez

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.

Kaiqgs avatar Jan 08 '22 13:01 Kaiqgs