List.selected readonly property


Get or set the current selected ListItem or nil

Example

local ui = require "ui" -- create a simple Window local win = ui.Window("List.selected sample", "fixed", 360, 150) local label = ui.Label(win, "Select an item :", 90, 30) local list = ui.List(win, {"LuaRT", "is", "fun !"}, label.x+label.width+6, label.y-4) -- set list selected property to the first item "LuaRT" list.selected = list.items[1] function list:onSelect(item) win:status("You have selected = "..item.text) end win:show() -- update user interface repeat ui.update() until not win.visible