This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
dev:v3:gui_api:menu:menu [2020/07/06 16:06] – jedi18 | dev:v3:gui_api:menu:menu [2020/07/07 04:18] (current) – jedi18 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Menu GUI Class ====== | + | ====== Menu Item GUI Class ====== |
- | [[https:// | + | [[https:// |
<code cpp-qt> namespace lc::ui::api </ | <code cpp-qt> namespace lc::ui::api </ | ||
---- | ---- | ||
- | ===== Menu Constructor ===== | + | ===== Menu Item Constructor ===== |
---- | ---- | ||
Line 10: | Line 10: | ||
==== Description ==== | ==== Description ==== | ||
- | Constructs a menu gui object. Menu after being constructed needs to be added to the mainwindow menu bar or to another | + | 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 Name - //string// | + | * Menu Item Name - //string// |
+ | * Menu Item Name - //string// , Lua Callback - // | ||
==== Examples ==== | ==== Examples ==== | ||
- | * <code lua> local menu1 = gui.Menu("Test" | + | * <code lua> local item1 = gui.MenuItem("Item1")</ |
+ | * <code lua> local item1 = gui.MenuItem(" | ||
---- | ---- | ||
- | ===== Add Menu Item ===== | + | ===== Add Callback |
---- | ---- | ||
Line 25: | Line 27: | ||
==== Description ==== | ==== Description ==== | ||
- | Add menu item to the menu. The item is added to the end of the menu at the last position. | + | Add lua function callback |
- | * Menu Item Label - //string// , Lua Callback - // | + | * Lua Callback - // |
- | * returns //MenuItem// | + | * Callback name - // |
- | * Menu Item Label - //string// | + | |
- | * return // | + | |
- | * Pointer to Menu Item - //MenuItem*// | + | |
==== Examples ==== | ==== Examples ==== | ||
- | * <code lua> | + | * <code lua> item1:addCallback(function() run_command("LINE") end) </ |
- | * <code lua> | + | * <code lua> item1:addCallback("message_callback", function() message(" |
- | * <code lua> local item1 = gui.MenuItem(" | + | |
- | | + | |
---- | ---- | ||
- | ===== Add Menu ===== | + | ===== Remove Callback |
---- | ---- | ||
Line 48: | Line 45: | ||
==== Description ==== | ==== Description ==== | ||
- | Add menu to the menu, menu is added at the end of the menu at the last position. | + | Remove lua function called associated with the given name. Only named callbacks can be removed. |
- | * Menu Label - //string// | + | * Callback name - //string// |
- | * return //Menu// | + | |
- | * Pointer to Menu - //Menu*// | + | |
==== Examples ==== | ==== Examples ==== | ||
- | * <code lua> | + | * <code lua> |
- | * <code lua> local menu2 = gui.Menu(" | + | |
- | | + | |
---- | ---- | ||
Line 68: | Line 61: | ||
==== Description ==== | ==== Description ==== | ||
- | Get and set label for the menu. | + | Get and set label for the menu item. |
==== Examples ==== | ==== Examples ==== | ||
- | * <code lua> message(menu1:label()) </ | + | * <code lua> message(item1:label()) </ |
- | * <code lua> | + | * <code lua> |
---- | ---- | ||
- | ===== Find Menu Item ===== | + | ===== Hide and Show ===== |
---- | ---- | ||
Line 83: | Line 76: | ||
==== Description ==== | ==== Description ==== | ||
- | Find menu item by name or by position in the menu. Return nullptr if dosen' | + | Hide or show the menu item. |
- | + | ||
- | * Menu Item Label - // | + | |
- | * return // | + | |
- | * Position of menu item - //int// | + | |
- | * return // | + | |
==== Examples ==== | ==== Examples ==== | ||
- | * <code lua> | + | * <code lua> item1:hide() </ |
- | * <code lua> | + | * <code lua> |
---- | ---- | ||
- | ===== Find Menu ===== | + | ===== Position |
---- | ---- | ||
Line 103: | Line 91: | ||
==== Description ==== | ==== Description ==== | ||
- | Find menu by name or by position | + | Get the current |
- | * Menu Label - // | + | * New Position - //int// |
- | * return //Menu// | + | |
- | * Position | + | |
- | * return //Menu// | + | |
==== Examples ==== | ==== Examples ==== | ||
- | * <code lua> local menu2 = menu1:menuByName(" | + | * <code lua> local pos = item1:position() </ |
- | * <code lua> | + | * <code lua> |
---- | ---- | ||
- | ===== Remove | + | ===== Remove ===== |
---- | ---- | ||
Line 123: | Line 108: | ||
==== Description ==== | ==== Description ==== | ||
- | Remove | + | Remove the current |
- | + | ||
- | * Menu Item Label - // | + | |
- | * Pointer to Menu Item - // | + | |
- | + | ||
- | ==== Examples ==== | + | |
- | + | ||
- | * <code lua> menu1: | + | |
- | * <code lua> menu1: | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | ===== Remove Menu ===== | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | ==== Description ==== | + | |
- | + | ||
- | Remove menu by name or by passing in the menu. Dosen' | + | |
- | + | ||
- | * Menu Label - // | + | |
- | * Pointer to Menu - //Menu// | + | |
==== Examples ==== | ==== Examples ==== | ||
- | * <code lua> | + | * <code lua> |
- | * <code lua> menu1: | + | |
---- | ---- |