Menu:insert(index, [caption])method
Insert an item in the Menu, at the specified index, with an optional submenu.
Parameters
Parameters
index
A number representing the item position in the Menu, starting at 1
[caption]
An optional string representing the item caption.
Return value
This function returns the inserted MenuItemExample
--! luart-extensions
import ui
-- create a simple Window
local win = ui.Window("Menu:insert() sample", 316, 246)
-- ultra concise Menu creation with menu:insert()
win.menu = ui.Menu()
win.menu:insert(1, "Items", ui.Menu("Item 1", "Item 2", "Item 3")).submenu.onClick = function (self, item)
ui.info("You have clicked on "..item.text)
end
-- shows the Window
win:show()
-- update user interface
repeat
ui.update()
until not win.visible