Menu:insert(index, [ caption ], [ submenu ]) method


Insert an item in the Menu, at the specified index, with an optional submenu.

Parameters

index

A number representing the item position in the Menu, starting at 1

caption

An optional string representing the item caption.

submenu

An optional submenu Menu object associated with the just inserted menu item.

Return value

This function returns the inserted MenuItem

Example

local ui = require "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