When no argument or a
nil
path value is provided, the MenuItem icon will be removed.MenuItem:loadicon([path], [index]) method
Loads an item icon, displayed to the left of the item's text.
Parameters
[path]
Represent any of the following possible icon locations :
[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("MenuItem:loadicon() sample", 316, 246)
-- create a Window menu
win.menu = ui.Menu()
-- insert a "File" item with a submenu
local FileMenu = win.menu:add("File", ui.Menu("New", "Open", "Save", "Quit")).submenu
function FileMenu:onClick(item)
ui.info("You have clicked on "..item.text)
end
-- icons should be placed in "icons" subdirectory, named by their item.text
for item in each(FileMenu.items) do
item:loadicon("./icons/"..item.text..".ico")
end
-- shows the Window
win:show()
-- update user interface
repeat
ui.update()
until not win.visible