Files
Basalt/docs/objects/Button.md
Robert Jelic 4d614372a1 Updated docs
There is still stuff to do
2022-08-28 18:18:26 +02:00

1.1 KiB

The button object is for creating buttons If you click on them, they should execute something. You decide what should happen when clicking on them.

Object methods also apply for buttons.

setText Changes the button text
setHorizontalAlign Changes the horizontal text position
setVerticalAlign Changes the vertical text position

Example

This is a example on how you would create a fully working button:

local main = basalt.createFrame()
local aButton = main:addButton():setText("Click")

aButton:onClick(function(self,event,button,x,y)
  if(event=="mouse_click")and(button==1)then
    basalt.debug("Left mousebutton got clicked!")
  end
end)

and this would be the xml way:

local main = basalt.createFrame():addLayout("example.xml")

basalt.setVariable("buttonClick", function(self,event,button,x,y)
  if(event=="mouse_click")and(button==1)then
    basalt.debug("Left mousebutton got clicked!")
  end
end)
<button onClick="buttonClick" text="Click" />