Tree.selected readonly property


Get or set the current selected TreeItem or nil if no selection has been made.

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 tree.selected:remove() end win:show() -- update user interface repeat ui.update() removebtn.enabled = tree.selected ~= nil until not win.visible