Be sure to set the Tree.readonly property to
true
before beginning in-place editing.TreeItem:edit() method
Begins in-place editing of the specified TreeItem's caption.
When the user has done editing it, the parent Tree will receive a Tree:onChange() event.
Return value
This function returns no value.Example
local ui = require "ui"
local win = ui.Window("Tree:onChange() sample", "fixed", 320, 240)
local tree = ui.Tree(win, {"Item 1", "Item 2", ["Item 3"] = {"Subitem1", "Subitem2"}}, 110, 40)
local edited = nil
win:status("Doubleclick on an item to edit it")
-- Tree onDoubleClick() event
function tree:onDoubleClick(item)
edited = tree.selected.text
tree.selected:edit()
end
-- Tree onChange() event
function tree:onChange(item, action)
if action == "edited" then
win:status(edited.." has been renamed to "..item.text)
end
end
-- show the Window
win:show()
while win.visible do
ui.update()
end