GuiButton
An abstract class for interactive 2D user interface elements.
Memory category | Gui |
---|
Member index 17
Removed member index 1
History | Member | |
---|---|---|
402 | SetVerb(verb: string): void |
Description
GuiButton is an abstract class that inherits from GuiObject. It is the base class for ImageButton and TextButton. Objects of this type serve to be interactive, clickable user interface elements. It defines several properties for interaction behavior, namely GuiButton.AutoButtonColor and GuiButton.Modal, as well as a handful of events for mouse buttons (GuiButton.MouseButton1Click, GuiButton.MouseButton1Down, etc).
The most important event of a GuiButton is GuiButton.Activated, a multi-platform event that fires when the button is activated. When using a mouse, this means clicking the button and releasing with the cursor still over the UI object. For touch, the same applies but with a touch instead of button press. Finally, for gamepads, GuiButton.Activated fires if a GuiButton is selected when the A-button is pressed and released. In short, this event is very useful for multi-platform user interface programming as it provides a nice general interface for a single user input.
History 43
- 578 Change Category of Selected from Data to Selection
- 553 Change Default of Style from to
- 553 Change Default of Selected from to
- 553 Add
- 553 Add
- 553 Add
- 553 Add
- 553 Add
- 553 Add
- 553 Change Default of Modal from to
- 553 Change Default of AutoButtonColor from to
- 486 Change ThreadSafety of Style from ReadOnly to ReadSafe
- 486 Change ThreadSafety of Selected from ReadOnly to ReadSafe
- 486 Change ThreadSafety of Modal from ReadOnly to ReadSafe
- 486 Change ThreadSafety of AutoButtonColor from ReadOnly to ReadSafe
- 483 Change Parameters of Activated from (inputObject: Instance, clickCount: int) to (inputObject: InputObject, clickCount: int)
- 462 Change ThreadSafety of MouseButton2Up from to Unsafe
- 462 Change ThreadSafety of MouseButton2Down from to Unsafe
- 462 Change ThreadSafety of MouseButton2Click from to Unsafe
- 462 Change ThreadSafety of MouseButton1Up from to Unsafe
- 462 Change ThreadSafety of MouseButton1Down from to Unsafe
- 462 Change ThreadSafety of MouseButton1Click from to Unsafe
- 462 Change ThreadSafety of Activated from to Unsafe
- 462 Change ThreadSafety of Style from to ReadOnly
- 462 Change ThreadSafety of Selected from to ReadOnly
- 462 Change ThreadSafety of Modal from to ReadOnly
- 462 Change ThreadSafety of AutoButtonColor from to ReadOnly
- 423 Change Parameters of Activated from (inputObject: Instance) to (inputObject: Instance, clickCount: int)
- 402 Remove SetVerb
- 304 Add Activated
- 55 Change Tags of GuiButton from [NotCreatable] to [NotCreatable, NotBrowsable]
- 47 Add MouseButton2Up
- 47 Add MouseButton2Down
- 47 Add MouseButton2Click
- 47 Add MouseButton1Up
- 47 Add MouseButton1Down
- 47 Add MouseButton1Click
- 47 Add SetVerb
- 47 Add Style
- 47 Add Selected
- 47 Add Modal
- 47 Add AutoButtonColor
- 47 Add GuiButton
Members 17
Activated
Parameters (2) | |
---|---|
inputObject | InputObject |
clickCount | int |
Fires when the button is activated. As this event doesn't fire on the server, it should only be used in a LocalScript, or in a Script with RunContext of RunContext.Client.
Thread safety | Unsafe |
---|
History 4
- 483 Change Parameters of Activated from (inputObject: Instance, clickCount: int) to (inputObject: InputObject, clickCount: int)
- 462 Change ThreadSafety of Activated from to Unsafe
- 423 Change Parameters of Activated from (inputObject: Instance) to (inputObject: Instance, clickCount: int)
- 304 Add Activated
AutoButtonColor
Type | Default | |
---|---|---|
bool |
The AutoButtonColor determines whether the button automatically changes color when the user's Mouse hovers over or clicks on it.
If true, the button will automatically change color when the mouse hovers over or clicks on it. If false, the button will not change.
If you would like to customize how a button changes when the user's mouse hovers over or clicks on it, consider using an ImageButton GUI and changing the element's ImageButton.HoverImage and ImageButton.PressedImage.
Please note that this property will not have an effect on an ImageButton if it's ImageButton.Image property is set to an image and is not null. Additionally, the property will not affect an ImageButton element on mouse hover when its ImageButton.HoverImage is not null nor on mouse click if ImageButton.PressedImage is not null.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | true |
History 4
- 553 Change Default of AutoButtonColor from to
- 486 Change ThreadSafety of AutoButtonColor from ReadOnly to ReadSafe
- 462 Change ThreadSafety of AutoButtonColor from to ReadOnly
- 47 Add AutoButtonColor
Modal
Type | Default | |
---|---|---|
bool |
If true while the GUI element is visible, the mouse will not be locked unless the right mouse button is down.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | true |
MouseButton1Click
Parameters (0) | ||
---|---|---|
No parameters. |
The MouseButton1Click event fires when the user's Mouse fully left clicks the GUI button.
By clicking, the mouse has to be in bounds of the button and has to be
pressed down and up again before this event fires. If the mouse leaves the
bounds of the button and is released, the event will not fire. If you
would like to avoid this limitation, you can use
GuiButton.MouseButton1Down and MouseButton1Up
. These events are
similar, but will fire whenever the user pressed their left mouse down or
up, respectively.
This event is similar to GuiButton.MouseButton2Click, which behaves identically except that it is connected to the user's right mouse button.
Note that this event will only fire for GUI buttons, including TextButtons and ImageButton. It will not fire for other GuiObjects.
Thread safety | Unsafe |
---|
History 2
- 462 Change ThreadSafety of MouseButton1Click from to Unsafe
- 47 Add MouseButton1Click
MouseButton1Down
Parameters (2) | |
---|---|
x | int |
y | int |
The MouseButton1Down event fires when the user presses their left Mouse button down on the GUI object.
This event is similar to GuiButton.MouseButton2Down, which behaves identically except that it is connected to the user's right mouse button.
If you are looking for an event requiring the user to press and release their left mouse on a GUI in order for the event to fire, consider using GuiButton.MouseButton1Click.
Note that this event will only fire for GUI buttons, including TextButtons and ImageButton. It will not fire for other GuiObjects.
Thread safety | Unsafe |
---|
History 2
- 462 Change ThreadSafety of MouseButton1Down from to Unsafe
- 47 Add MouseButton1Down
MouseButton1Up
Parameters (2) | |
---|---|
x | int |
y | int |
The MouseButton1Up event fires when the user releases their left Mouse up off of the GUI object.
This event is similar to GuiButton.MouseButton2Up, which behaves identically except that it is connected to the user's right mouse button.
If you are looking for an event requiring the user to press and release their left mouse on a GUI in order for the event to fire, consider using GuiButton.MouseButton1Click.
Note that this event will only fire for GUI buttons, including TextButtons and ImageButton. It will not fire for other GuiObjects.
Thread safety | Unsafe |
---|
History 2
- 462 Change ThreadSafety of MouseButton1Up from to Unsafe
- 47 Add MouseButton1Up
MouseButton2Click
Parameters (0) | ||
---|---|---|
No parameters. |
The MouseButton2Click event fires when the user's Mouse fully right clicks the GUI button.
By clicking, the mouse has to be in bounds of the button and has to be
pressed down and up again before this event fires. If the mouse leaves the
bounds of the button and is released, the event will not fire. If you
would like to avoid this limitation, you can use
GuiButton.MouseButton2Down and MouseButton2Up
. These events are
similar, but will fire whenever the user pressed their left mouse down or
up, respectively.
This event is similar to GuiButton.MouseButton1Click, which behaves identically except that it is connected to the user's left mouse button.
Note that this event will only fire for GUI buttons, including TextButtons and ImageButton. It will not fire for other GuiObjects.
Thread safety | Unsafe |
---|
History 2
- 462 Change ThreadSafety of MouseButton2Click from to Unsafe
- 47 Add MouseButton2Click
MouseButton2Down
Parameters (2) | |
---|---|
x | int |
y | int |
The MouseButton2Down event fires when the user presses their right Mouse button down on the GUI object.
This event is similar to GuiButton.MouseButton1Down, which behaves identically except that it is connected to the user's left mouse button.
If you are looking for an event requiring the user to press and release their right mouse on a GUI in order for the event to fire, consider using GuiButton.MouseButton2Click.
Note that this event will only fire for GUI buttons, including TextButtons and ImageButton. It will not fire for other GuiObjects.
Thread safety | Unsafe |
---|
History 2
- 462 Change ThreadSafety of MouseButton2Down from to Unsafe
- 47 Add MouseButton2Down
MouseButton2Up
Parameters (2) | |
---|---|
x | int |
y | int |
The MouseButton2Up event fires when the user releases their right Mouse up off of the GUI object.
This event is similar to GuiButton.MouseButton1Up, which behaves identically except that it is connected to the user's left mouse button.
If you are looking for an event requiring the user to press and release their right mouse on a GUI in order for the event to fire, consider using GuiButton.MouseButton2Click.
Note that this event will only fire for GUI buttons, including TextButtons and ImageButton. It will not fire for other GuiObjects.
Thread safety | Unsafe |
---|
History 2
- 462 Change ThreadSafety of MouseButton2Up from to Unsafe
- 47 Add MouseButton2Up
Selected
Type | Default | |
---|---|---|
bool |
A boolean property which indicates whether the object has been selected.
Thread safety | ReadSafe |
---|---|
Category | Selection |
Loaded/Saved | true |
Style
Type | Default | |
---|---|---|
ButtonStyle |
Sets the style of the GuiButton based on a list of pre-determined styles.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | true |