• 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 16:06] – 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>+
  
 ---- ----
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> +  * <code lua> message(item1:label()) </code> 
-  * <code lua> menu1:setLabel("New Label")</code>+  * <code lua> item1:setLabel("New Label")</code>
  
 ---- ----
  
-===== 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't exist or position is invalid. +Hide or show the menu item.
- +
-  * Menu Item Label - //string// +
-    * return //MenuItem// +
-  * Position of menu item - //int// +
-    * return //MenuItem//+
  
 ==== Examples ==== ==== Examples ====
  
-  * <code lua> local item1 = menu1:itemByName("Item1") </code> +  * <code lua> item1:hide() </code> 
-  * <code lua> local item2 = menu1:itemByPosition(1) </code>+  * <code lua> item1:show() </code>
  
 ---- ----
  
-===== Find Menu =====+===== Position =====
  
 ---- ----
Line 103: Line 91:
 ==== Description ==== ==== Description ====
  
-Find menu by name or by position in the menu. Return nullptr if dosen't exist or position is invalid.+Get the current menu item position or set the menu item position. Other items are rearranged accordingly.
  
-  * Menu Label - //string// +  * New Position - //int//
-    * return //Menu// +
-  * Position of menu - //int// +
-    * return //Menu//+
  
 ==== Examples ==== ==== Examples ====
  
-  * <code lua> local menu2 = menu1:menuByName("Menu2") </code> +  * <code lua> local pos = item1:position() </code> 
-  * <code lua> local menu2 = menu1:menuByPosition(1) </code>+  * <code lua> item1:setPosition(2) </code>
  
 ---- ----
  
-===== Remove Menu Item =====+===== Remove =====
  
 ---- ----
Line 123: Line 108:
 ==== Description ==== ==== Description ====
  
-Remove menu item by name or by passing in the menu item. Dosen't do anything if item dosen't exist or is nullptr. +Remove the current menu item from the parent menu.
- +
-  * Menu Item Label - //string// +
-  * Pointer to Menu Item - //MenuItem// +
- +
-==== Examples ==== +
- +
-  * <code lua> menu1:removeItem("Item1") </code> +
-  * <code lua> menu1:removeItem(item1) </code> +
- +
----- +
- +
-===== Remove Menu ===== +
- +
----- +
- +
-==== Description ==== +
- +
-Remove menu by name or by passing in the menu. Dosen't do anything if menu dosen't exist or is nullptr. +
- +
-  * Menu Label - //string// +
-  * Pointer to Menu - //Menu//+
  
 ==== Examples ==== ==== Examples ====
  
-  * <code lua> menu1:removeMenu("Menu2") </code> +  * <code lua> item1:remove() </code>
-  * <code lua> menu1:removeMenu(menu2) </code>+
  
 ---- ----
dev/v3/gui_api/menu/menu.1594051573.txt.gz · Last modified: 2020/07/06 16:06 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