Button

Buttons are user interface elements allowing users to take actions.

Button is a shortcut to Client.UI.Button.

Buttons are automatically displayed on the screen upon creation.

Constructors

Button ( string text optional, Anchor hAnchor optional, Anchor vAnchor optional )

Creates a Button with optional parameters:
- text displayed text
- horizontal_anchor possible values: Anchor.Left, Anchor.HCenter, Anchor.Right (defaut)
- vertical_anchor possible values: Anchor.Top (defaut), Anchor.VCenter, Anchor.Bottom

-- adds a button at top right of the screen
local btn1 = Button("I'm a button")
-- adds a button at the center of the screen
local btn2 = Button("I'm a button", Anchor.HCenter, Anchor.VCenter)

Functions

nil Add ( Anchor hAnchor optional, Anchor vAnchor optional )

Displays a button that has been removed.
By default, original anchors are kepts, but it's possible to supply new ones.

Calling Add for a button that's already displayed has no effect.

myButton = Button("do something")
-- by default, the button is displayed upon creation
-- let's remove it:
myButton:Remove()
-- we can add it back with different anchors: 
btn:Add(Anchor.Center, Anchor.Bottom)
nil Remove ( )

Removes the Button.

-- removes button from screen
btn:Remove()

Properties

Button's color.

-- set button color
local btn = Button("test button")
btn.Color = Color(255, 0, 0) -- make it red

Function triggered when pressing the button.

-- set button's press callback
local btn = Button("test button")
btn.OnPress = function()
  print("button pressed")
end

Function triggered when releasing the button.

-- set button's release callback
local btn = Button("test button")
btn.OnRelease = function()
  print("button released")
end

Text being displayed by the Button.

-- update displayed text
local btn = Button()
btn.Text = "test button"

Button's text color.

-- set button text color
local btn = Button()
btn.TextColor = Color(100, 0, 0)