Tree:remove(text | item) method
Remove an item from the Tree.
text | item
A string, representing the item's text or the TreeItem to be removed.Return value
This function returns no value.Example
local ui = require "ui"
-- create a simple Window
local win = ui.Window("Tree:remove() sample", "fixed", 310, 200)
local label = ui.Label(win, "Select item :", 10, 30)
local tree = ui.Tree(win, { ["RootItem1"] = {"RootItem1.SubItem1", "RootItem1.SubItem2"}, "RootItem2", "RootItem3"}, label.x+label.width+6, label.y-4)
local removebtn = ui.Button(win, "Remove item", tree.x+tree.width+6, label.y-4)
removebtn.enabled = false
function removebtn:onClick()
-- removes current selected item
-- alternative 1: tree.remove(item.selected)
-- alternative 2: tree.selected:remove()
tree:remove(tree.selected.text)
end
win:show()
-- update user interface
repeat
ui.update()
removebtn.enabled = tree.selected ~= nil
until not win.visible