Tab.items read/write propertyiterable


Provides access to the list of Tab items.

Reading this property returns a table that contains a list of TabItem. This table can be indexed by item index or by item text. The item position starts from 1. Using a wrong index or an invalid text will return a nil value.

Setting this property will change all the items in the List. It expects a table that contains a list of strings (each string will be an item in the Tab)

This property is iterable, with the each() or ipairs() function, returning ListItem one by one at each iteration.

Example

local ui = require "ui" -- create a simple Window local win = ui.Window("Tab.items sample", 464, 232) local label = ui.Label(win, "Enter an item index : ", 20, 30) local entry = ui.Entry(win, "1", label.x+label.width+6, label.y-4, 22, 22) local tab = ui.Tab(win, {}, entry.x+entry.width+6, label.y-4) -- change all items in the tab tab.items = { "LuaRT", "is", "fun"} -- disable the tab tab.enabled = false -- Event fired when user press RETURN in the Entry field function entry:onSelect() local item = tab.items[entry.text] or false if item then tab.selected = item else ui.error(entry.text.." is not a valid index") end print("Selected item = "..item.text) end win:show() -- update user interface repeat ui.update() until not win.visible