TreeItem:add(itemtext1 [, itemtext2...]) method
Add one or more subitems to the TreeItem.
itemtext1 [, itemtext2...]
One or more strings representing the text of the new subitems.These items can later be accessed using the TreeItem.subitems property, as TreeItems objects.
Return value
This function returns the last added TreeItemExample
local ui = require "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