User Tools

Site Tools


Sidebar

Introduction

* Home

Documentation & help

LibreCAD Community

Help on DokuWiki

Temporary shorcuts

dev:v3:gui_api:menu:menu

This is an old revision of the document!


Menu GUI Class

Github Link

 namespace lc::ui::api 


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.

  • Menu Name - string

Examples

  •  local menu1 = gui.Menu("Test")

Add Menu Item


Description

Add menu item to the menu. The item is added to the end of the menu at the last position.

  • Menu Item Label - string , Lua Callback - kaguya::LuaRef
    • returns MenuItem
  • Menu Item Label - string
    • return MenuItem
  • Pointer to Menu Item - MenuItem*

Examples

  •  local item1 = menu1:addItem("Item1") 
  •  local item1 = menu1:addItem("Item1", function() message("Test Item Clicked") end) 
  •  local item1 = gui.MenuItem("Item1")
     menu1:addItem(item1) 

Add Menu


Description

Add menu to the menu, menu is added at the end of the menu at the last position.

  • Menu Label - string
    • return Menu
  • Pointer to Menu - Menu*

Examples

  •  local menu2 = menu1:addMenu("Menu2") 
  •  local menu2 = gui.Menu("Menu2")
     menu1:addMenu(menu2) 

Label


Description

Get and set label for the menu.

Examples

  •  message(menu1:label()) 
  •  menu1:setLabel("New Label")

Find Menu Item


Description

Find menu item by name or by position in the menu. Return nullptr if dosen't exist or position is invalid.

  • Menu Item Label - string
    • return MenuItem
  • Position of menu item - int
    • return MenuItem

Examples

  •  local item1 = menu1:itemByName("Item1") 
  •  local item2 = menu1:itemByPosition(1) 

Find Menu


Description

Find menu by name or by position in the menu. Return nullptr if dosen't exist or position is invalid.

  • Menu Label - string
    • return Menu
  • Position of menu - int
    • return Menu

Examples

  •  local menu2 = menu1:menuByName("Menu2") 
  •  local menu2 = menu1:menuByPosition(1) 

Remove Menu Item


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.

  • Menu Item Label - string
  • Pointer to Menu Item - MenuItem

Examples

  •  menu1:removeItem("Item1") 
  •  menu1:removeItem(item1) 

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

  •  menu1:removeMenu("Menu2") 
  •  menu1:removeMenu(menu2) 

dev/v3/gui_api/menu/menu.1594051573.txt.gz · Last modified: 2020/07/06 16:06 by jedi18