• skip to content

Wiki

User Tools

  • Admin
  • Log In

Site Tools

  • Recent Changes
  • Media Manager
  • Sitemap
Trace:

dev:v3:gui_api:menu:menu

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
dev:v3:gui_api:menu:menu [2020/07/06 15:51] – jedi18dev:v3:gui_api:menu:menu [2020/07/07 04:18] (current) – jedi18
Line 1: Line 1:
-====== Menu GUI Class ====== +====== Menu Item GUI Class ====== 
-[[https://github.com/LibreCAD/LibreCAD_3/blob/master/lcUI/widgets/guiAPI/menu.h|Github Link]]+[[https://github.com/LibreCAD/LibreCAD_3/blob/master/lcUI/widgets/guiAPI/menuitem.h|Github Link]]
 <code cpp-qt> namespace lc::ui::api </code> <code cpp-qt> namespace lc::ui::api </code>
 ---- ----
  
-===== 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 menu for it to be visible in the application.+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 - //kaguya::LuaRef//
  
 ==== Examples ==== ==== Examples ====
  
-  * <code lua> local menu1 = gui.Menu("Test")</code>+  * <code lua> local item1 = gui.MenuItem("Item1")</code> 
 +  * <code lua> local item1 = gui.MenuItem("Item1", function() message("Item1 Clicked") end)</code>
  
 ---- ----
-===== 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 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.
  
-  * Menu Item Label - //string// , Lua Callback - //kaguya::LuaRef// +  * Lua Callback - //kaguya::LuaRef// 
-    * returns //MenuItem// +  * Callback name - //string// , Lua Callback - //kaguya::LuaRef//
-  * Menu Item Label - //string// +
-    * return //MenuItem// +
-  * Pointer to Menu Item - //MenuItem*//+
  
 ==== Examples ==== ==== Examples ====
  
-  * <code lua> local item1 = menu1:addItem("Item1") </code> +  * <code lua> item1:addCallback(function() run_command("LINE") end) </code> 
-  * <code lua> local item1 = menu1:addItem("Item1", function() message("Test Item Clicked") end) </code> +  * <code lua> item1:addCallback("message_callback", function() message("Test") end) </code>
-  * <code lua> local item1 = gui.MenuItem("Item1") +
- menu1:addItem(item1) </code>+
  
 ---- ----
  
-===== 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> local menu2 = menu1:addMenu("Menu2") </code> +  * <code lua> item1:removeCallback("message_callback") </code>
-  * <code lua> local menu2 = gui.Menu("Menu2") +
- menu1:addMenu(menu2) </code>+
  
 ---- ----
  
 +===== Label =====
 +
 +----
 +
 +==== Description ====
 +
 +Get and set label for the menu item.
 +
 +==== Examples ====
 +
 +  * <code lua> message(item1:label()) </code>
 +  * <code lua> item1:setLabel("New Label")</code>
 +
 +----
 +
 +===== Hide and Show =====
 +
 +----
 +
 +==== Description ====
 +
 +Hide or show the menu item.
 +
 +==== Examples ====
 +
 +  * <code lua> item1:hide() </code>
 +  * <code lua> item1:show() </code>
 +
 +----
 +
 +===== Position =====
 +
 +----
 +
 +==== Description ====
 +
 +Get the current menu item position or set the menu item position. Other items are rearranged accordingly.
 +
 +  * New Position - //int//
 +
 +==== Examples ====
 +
 +  * <code lua> local pos = item1:position() </code>
 +  * <code lua> item1:setPosition(2) </code>
 +
 +----
 +
 +===== Remove =====
 +
 +----
 +
 +==== Description ====
 +
 +Remove the current menu item from the parent menu.
 +
 +==== Examples ====
 +
 +  * <code lua> item1:remove() </code>
 +
 +----
dev/v3/gui_api/menu/menu.1594050702.txt.gz · Last modified: 2020/07/06 15:51 by jedi18

Page Tools

  • Show page
  • Old revisions
  • Backlinks
  • Export to PDF
  • Rename Page
  • Back to top
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki