Button
Buttons are used to trigger actions.
Playground
Use the switch to enable the sub button and edit its label.
Usage
You can create a Button by calling the AddButton method on a Groupbox.
Choose between positional arguments for quick calls or a configuration table for more customization.
Positional Arguments
Groupbox:AddButton("This is a button", function()
print("Button clicked!")
end)| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Text of the button | string | nil |
| 2 | Callback function | function | nil |
Configuration Table
Groupbox:AddButton({
Text = "This is a button",
Func = function()
print("Button clicked!")
end
})Prop
Type
Methods
You can use the following methods to interact with the button:
Destroy
Destroys the button and removes it from the UI.
MainButton:Destroy()Sub Button
You can also add a sub button to a button.
local MainButton = Groupbox:AddButton({
Text = "Button",
Func = function()
print("Button clicked!")
end
})
MainButton:AddButton({
Text = "Sub Button",
Func = function()
print("Sub button clicked!")
end
})KeyPicker
You can add a KeyPicker to a button. Note that this only works with the 'Press' mode of the KeyPicker.
When the button is triggered by the KeyPicker, the callback will receive true as the FromKeyPicker argument.
local CoolButton = Groupbox:AddButton({
Text = "Cool Button",
Func = function(FromKeyPicker)
if FromKeyPicker then
print("Button was triggered by the Key Picker!")
else
print("Button was clicked manually!")
end
end
})
CoolButton:AddKeyPicker("ButtonKeyPicker", {
Default = "V",
Text = "Button Bind",
Mode = "Press",
})