Combobox:clear() method


Remove all items from the Combobox.

Return value

This function returns no value.

Example

local ui = require "ui" -- create a simple Window local win = ui.Window("Combobox:clear() sample", "fixed", 320, 110) local label = ui.Label(win, "New item :", 10, 25) 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 combobox = ui.Combobox(win, {}, button.x+button.width+6, label.y-4) local clearbtn = ui.Button(win, "Clear all", 230, 54) function clearbtn:onClick() combobox:clear() end function button:onClick() -- add new item in the Combobox adn select it combobox:add(entry.text) combobox.selected = combobox.items[#combobox.items] entry.text = "" win:status("Combobox.count = "..combobox.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("Combobox.count = 0") win:show() -- update user interface repeat ui.update() until not win.visible