Skip to content
Robert Jelic edited this page Apr 24, 2022 · 12 revisions

Buttons are objects, which execute function by clicking on them

Here is a example of how to create a standard button:

local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):show()

This will create a default button with the size 5 width and 1 height on position 1 1 (relative to its parent frame), the default background is colors.lightBlue, the default text color is colors.black and the default zIndex is 5. The default vertical and horizontal text aligns are "center" - but there is no default text.

Here are all possible functions available for buttons. Remember button inherit from object:

setText

Sets the displayed button text

local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setText("Click"):show() -- you could also use :setValue() instead of :setText() - no difference

args: text
returns: the object

Examples

Add a onClick event:

local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setText("Click"):onClick(function(self,event,button,x,y)
if(event=="mouse_click")and(button==1)then
basalt.debug("Left mousebutton got clicked!")
end
end):show()

Wiki Navigation

Home
Clone this wiki locally