====== Menu Item GUI Class ====== [[https://github.com/LibreCAD/LibreCAD_3/blob/master/lcUI/widgets/guiAPI/menuitem.h|Github Link]] namespace lc::ui::api ---- ===== Menu Item Constructor ===== ---- ==== Description ==== 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. * Menu Item Name - //string// * Menu Item Name - //string// , Lua Callback - //kaguya::LuaRef// ==== Examples ==== * local item1 = gui.MenuItem("Item1") * local item1 = gui.MenuItem("Item1", function() message("Item1 Clicked") end) ---- ===== Add Callback ===== ---- ==== Description ==== 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. * Lua Callback - //kaguya::LuaRef// * Callback name - //string// , Lua Callback - //kaguya::LuaRef// ==== Examples ==== * item1:addCallback(function() run_command("LINE") end) * item1:addCallback("message_callback", function() message("Test") end) ---- ===== Remove Callback ===== ---- ==== Description ==== Remove lua function called associated with the given name. Only named callbacks can be removed. * Callback name - //string// ==== Examples ==== * item1:removeCallback("message_callback") ---- ===== Label ===== ---- ==== Description ==== Get and set label for the menu item. ==== Examples ==== * message(item1:label()) * item1:setLabel("New Label") ---- ===== Hide and Show ===== ---- ==== Description ==== Hide or show the menu item. ==== Examples ==== * item1:hide() * item1:show() ---- ===== Position ===== ---- ==== Description ==== Get the current menu item position or set the menu item position. Other items are rearranged accordingly. * New Position - //int// ==== Examples ==== * local pos = item1:position() * item1:setPosition(2) ---- ===== Remove ===== ---- ==== Description ==== Remove the current menu item from the parent menu. ==== Examples ==== * item1:remove() ----