TreeItem:add()method
Add one or more subitems to the TreeItem.
Return value
This function returns the last added TreeItemExample
--! luart-extensions
import ui
local win = ui.Window("TreeItem:add() sample", 320, 220)
local tree = ui.Tree(win, {}, 60, 40, 200, 160)
tree.style = "icons"
local function parse(item, dir)
if dir ~= nil then
for entry in each(dir) do
local newitem = item:add(entry.name)
newitem:loadicon(entry)
ui.update()
if is(entry, sys.Directory) then
parse(newitem, entry)
end
end
end
end
ui.Button(win, "Choose a directory", 106, 10).onClick = function (self)
tree:clear()
parse(tree, ui.dirdialog())
end
win:show()
while win.visible do
ui.update()
end