Constructs a menu item gui object. Menu item after being constructed needs to be added to a menu for it to be visible in the application.
local item1 = gui.MenuItem("Item1")
local item1 = gui.MenuItem("Item1", function() message("Item1 Clicked") end)
Add lua function callback to be called when the menu item is clicked. Multiple callbacks can be added. Callbacks can also be named callbacks i.e. associated with a name so that it can be later removed by use of the name.
item1:addCallback(function() run_command("LINE") end)
item1:addCallback("message_callback", function() message("Test") end)
Remove lua function called associated with the given name. Only named callbacks can be removed.
item1:removeCallback("message_callback")
Get and set label for the menu item.
message(item1:label())
item1:setLabel("New Label")
Hide or show the menu item.
item1:hide()
item1:show()
Get the current menu item position or set the menu item position. Other items are rearranged accordingly.
local pos = item1:position()
item1:setPosition(2)
Remove the current menu item from the parent menu.
item1:remove()