Button:loadicon([path], [index]) method

Loads a Button icon, displayed to the left of the Button caption.

Parameters

[path]

Represent any of the following possible icon locations :

  • A string which represents the path to an ".ico" icon file, or gets the icon associated with the provided file/directory.
  • A Widget object, whose icon will be used by the Button.
  • A Directory or File object, representing an ".ico" file, or gets the icon associated with the provided file/directory.
  • A Buffer object, whose binary content will represent the icon.

When no argument or a nil path value is provided, the icon will be removed.

[index]

The icon index, an optional number starting from 1, that represent the icon to select.

Return value

The method return a boolean value, indicating wether the operation succeeded or not.

Example

local ui = require "ui" -- create a simple Window local win = ui.Window("Button:loadicon() sample", 320, 200) -- create a Button on this window, with "Desktop" as text, and a folder icon local button = ui.Button(win, " Desktop", 110, 80) button:loadicon(sys.env.USERPROFILE.."\\Desktop\\") function button:onClick() sys.cmd("start %USERPROFILE%/Desktop") end win:show() -- update the user interface until the user closes the Window repeat ui.update() until not win.visible