Menu.items read/write property iterable
Provides access to the list of Menu items.
Reading this property returns a table that contains a list of MenuItem. This table can be indexed by item index only. The item position starts from 1. Using a wrong index will return a nil value.
Setting this property will change all the items in the Menu. It expects a table that contains a list of strings (each string will be an item in the Menu)
Example
local ui = require "ui"
-- create a simple Window
local win = ui.Window("Menu.items sample", 316, 246)
local menu = ui.Menu()
menu.items = { "Item1", "Item2", "Item3" }
-- shows popup menu on right click
function win:onContext()
win:popup(menu)
end
-- set a Menu:onClick() event handler
function menu:onClick(item)
ui.info("You have clicked on '"..item.text.."'")
end
win:status("Right-click on the Window to show a popup Menu")
-- shows the Window
win:show()
-- update user interface
repeat
ui.update()
until not win.visible