Link Search Menu Expand Document

Button

A button that can be poked/clicked to perform an action.

Every button has a Label. Use label:setText(…) to set it:

 my_button.label:setText("this is my button")

Set onActivated to a function you’d like to be called when the button is pressed:

 my_button.onActivated = function()
  -- do something...
 end

You can also set the button’s default, highlighted and activated texture (see Surface documentation for image format caveats). Or if you just want a colored button, you can set its color. Set either color or texture to nil to remove that attribute.

Constructor

 my_button = Button(bounds)

Arguments

Name Type Description
bounds Bounds The button’s initial bounds.

Returns

Nothing


Methods

Button:setTexture (asset)

Sets the texture of the button Set to nil to remove the attribute.

Arguments

Name Type Description
asset Asset The texture asset

Returns

Nothing


Button:setColor (rgba)

Sets the color of the button Set to nil to remove the attribute.

Arguments

Name Type Description
rgba table A table with the desired color’s r, g, b and alpha values between 0-1, e.g. {0.8, 0.4, 0.8, 0.5}

Returns

Nothing