User Tools

Site Tools


Sidebar

Introduction

* Home

Documentation & help

LibreCAD Community

Help on DokuWiki

Temporary shorcuts

dev:v3:gui_api:toolbar:toolbarbutton

Toolbar Button GUI Class

Github Link

 namespace lc::ui::api 

Toolbar Button Constructor


Description

Constructs a toolbar button gui object. Button after being constructed needs to be added to a group for it to be visible in the application.

  • Toolbar Button Name - string , Icon Path - string , Lua Callback - kaguya::LuaRef , Tooltip(Default = “”) - string , Checkable(Default = false) - bool
  • Toolbar Button Name - string , Icon Path - string , Tooltip(Default = “”) - string , Checkable(Default = false) - bool

Examples

  •  local button1 = gui.ToolbarButton("Button1", "icon_path", function() message("Test") end) 
  •  local button1 = gui.ToolbarButton("Button1", "icon_path") 
  •  local button1 = gui.ToolbarButton("Button1", "icon_path", function() message("Test") end), "Tooltip", true) 

Add Callback


Description

Add lua function callback to be called when the toolbar button 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

  •  button1:addCallback(function() run_command("LINE") end) 
  •  button1: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

  •  button1:removeCallback("message_callback") 

Set tooltip


Description

Set the tooltip for the button.

  • New tooltip - string

Examples

  •  button1:setTooltip("New Tooltip") 

Label


Description

Get and set label for the toolbar button.

Examples

  •  message(button1:label()) 
  •  button1:setLabel("New Button")

Enable and Disable


Description

Enable or disable the toolbar button.

Examples

  •  button1:enable() 
  •  button1:disable() 

Hide and Show


Description

Hide or show the toolbar button.

Examples

  •  button1:hide() 
  •  button1:show() 

Remove


Description

Remove the current toolbar button from the group.

Examples

  •  button1:remove() 

Checkable


Description

Return if the button is checkable or not.

Examples

  •  local isCheckable = button1:checkable() 

dev/v3/gui_api/toolbar/toolbarbutton.txt · Last modified: 2020/07/07 09:06 by jedi18