List:remove(item)method
Remove an item from the List.
Parameters
Parameters
item
A number, representing the item index or the ListItem to be removed.Return value
This function returns no value.Example
--! luart-extensions
import ui
-- create a simple Window
local win = ui.Window("List:remove() sample", "fixed", 360, 160)
local label = ui.Label(win, "Select item :", 80, 30)
local list = ui.List(win, {"LuaRT", "is", "fun !"}, label.x+label.width+6, label.y-4)
local removebtn = ui.Button(win, "Remove item", list.x+list.width+6, label.y-4)
removebtn.enabled = false
function removebtn:onClick()
-- removes current selected item
list:remove(list.selected)
-- select an other item if available
if list.count > 0 then
list.selected = list.items[1]
end
end
win:show()
-- update user interface
repeat
ui.update()
removebtn.enabled = list.selected ~= nil
until not win.visible