Tree.style read/write property


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

  • "text" : Tree will display only text items (default).
  • "icons" : Tree will display text items with their icons, using TreeItem: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("tree.style sample", "fixed", 280, 240) local label = ui.Label(win, "DoubleClick on an application :", 10, 30) local tree = ui.Tree(win, {}, label.x, label.y+20, 180, 160) local checkicons = ui.Checkbox(win, "Show icons", tree.x+tree.width+12, label.y) local applications = { Notepad = "c:\\Windows\\notepad.exe", Console = 'c:\\Windows\\System32\\cmd.exe' } -- fill the Tree with items for app, path in pairs(applications) do tree.selected = tree:add(app) tree.selected:loadicon(path) end function tree:onDoubleClick(item) sys.cmd("start "..applications[item.text]) end function checkicons:onClick() tree.style = self.checked and "icons" or "text" win:status("Tree style : "..tree.style:capitalize()) end checkicons:onClick() win:show() repeat ui.update() until not win.visible