List.count readonly property
Get the current items count in the List.
Example
local ui = require "ui"
-- create a simple Window
local win = ui.Window("List.count sample", "fixed", 360, 170)
local label = ui.Label(win, "New item :", 30, 30)
local entry = ui.Entry(win, "", label.x+label.width+6, label.y-4)
local button = ui.Button(win, "Add item", entry.x+entry.width+6, label.y-6)
local list = ui.List(win, {}, button.x+button.width+6, label.y-4)
function button:onClick()
-- add new item in the List adn select it
list.selected = list:add(entry.text)
entry.text = ""
win:status("List.count = "..list.count)
end
-- enable button only if entry.text is not empty
function entry:onChange()
button.enabled = #entry.text > 0
end
entry.onSelect = button.onClick
entry:onChange()
win:status("List.count = 0")
win:show()
-- update user interface
repeat
ui.update()
until not win.visible