List.style read/write property


Get or set the current style, a string value, that specifies the List appearance :

  • "text" : List will display only text items (default).
  • "icons" : List will display text items with their icons, using ListItem:loadicon().
When setting the style property from "icons" to "text" all previously loaded icons are preserved.

Example

local ui = require "ui" -- create a simple Window local win = ui.Window("List.style sample", "fixed", 400, 240) local label = ui.Label(win, "DoubleClick on an application :", 10, 30) local list = ui.List(win, {}, label.x+label.width+6, label.y-4) local checkicons = ui.Checkbox(win, "Show icons", list.x+list.width+12, label.y) local applications = { Notepad = "c:\\Windows\\notepad.exe", Console = 'c:\\Windows\\System32\\cmd.exe' } for app, path in pairs(applications) do list.selected = list:add(app) list.selected:loadicon(path) end function list:onDoubleClick(item) sys.cmd("start "..applications[item.text]) end function checkicons:onClick() list.style = self.checked and "icons" or "text" win:status("list style : "..list.style:capitalize()) end win:show() -- update user interface repeat ui.update() until not win.visible