Tree:onChange(TreeItem | itemtext, action) event
This event is fired when an item have been removed or edited by the user after a call to TreeItem:edit().
Parameters
TreeItem | itemtext
If an item have been removed, this argument represent the item text as a stringIf an item have been edited, this argument represent the edited TreeItem.
action
A string that represent the change that occured :
Return value
The event 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 onChangek() 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