Tab:clear() method


Remove all items from the Tab.

Return value

This function returns no value.

Example

local ui = require "ui" -- create a simple Window local win = ui.Window("Tab.count sample", "fixed", 580, 240) local label = ui.Label(win, "New item :", 10, 15) 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 tab = ui.Tab(win, {}, button.x+button.width+6, label.y-6) local clearbtn = ui.Button(win, "Clear all", tab.x+tab.width+4, label.y-4) clearbtn.enabled = false function button:onClick() -- add new item in the Tab adn select it tab.selected = tab:add(entry.text) entry.text = "" clearbtn.enabled = true win:status("Tab.count = "..tab.count) end function clearbtn:onClick() tab:clear() self.enabled = false 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("Tab.count = 0") win:show() -- update user interface repeat ui.update() until not win.visible