GuiButton

Show Deprecated
Not Creatable
Not Browsable

GuiButton is an abstract class that inherits from GuiObject. It is the base class for the interactive, clickable ImageButton and TextButton objects. This class also defines several properties for interactive behavior, namely AutoButtonColor and Modal.

The most important event of a GuiButton is 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, 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.

Summary

Properties

  • Read Parallel

    Determines whether the button automatically changes color when the mouse hovers over or clicks on it.

  • Read Parallel

    If true while the GUI element is visible, the mouse will not be locked unless the right mouse button is down.

  • Read Parallel

    A boolean property which indicates whether the object has been selected.

  • Read Parallel

    Sets the style of the GuiButton based on a list of pre-determined styles.

Properties inherited from GuiObjectProperties inherited from GuiBase2d

Methods

Methods inherited from GuiObject

Events

Events inherited from GuiObjectEvents inherited from GuiBase2d

Properties

AutoButtonColor

Read Parallel

This property 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 and changing the element's HoverImage and PressedImage.

Please note that this property will not have an effect on an ImageButton if its Image property is set to an image. Additionally, this property will not affect an ImageButton on mouse hover when its HoverImage is not nil, nor on mouse click if its PressedImage is not nil.

Read Parallel

If true while the GUI element is visible, the mouse will not be locked unless the right mouse button is down.

Selected

Read Parallel

A boolean property which indicates whether the object has been selected.

Read Parallel

Sets the style of the GuiButton based on a list of pre-determined styles.

Methods

Events

Activated

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 Enum.RunContext.Client.

Parameters

inputObject: InputObject
clickCount: number

MouseButton1Click

This event fires when the user's mouse fully left clicks the GuiButton.

In regards to clicking, the mouse must be in bounds of the GuiButton and the mouse button must be pressed down and up again before this event fires. If the mouse leaves the bounds of the GuiButton and is released, the event will not fire. If you would like to avoid this limitation, you can use MouseButton1Down and MouseButton1Up; these events are similar but will fire whenever the user presses their left mouse button down or up, respectively.


MouseButton1Down

This event fires when the user presses their left mouse button down on the GuiButton.

For an event requiring the user to press and release their left mouse on a GuiButton in order for the event to fire, consider using MouseButton1Click.

Parameters

The mouse's X screen coordinate in pixels.

The mouse's Y screen coordinate in pixels.


MouseButton1Up

This event fires when the user releases their left mouse button off of the GuiButton.

For an event requiring the user to press and release their left mouse on a GuiButton in order for the event to fire, consider using MouseButton1Click.

Parameters

The mouse's X screen coordinate in pixels.

The mouse's Y screen coordinate in pixels.


MouseButton2Click

This event fires when the user's mouse fully right clicks the GuiButton.

In regards to clicking, the mouse must be in bounds of the GuiButton and the mouse button must be pressed down and up again before this event fires. If the mouse leaves the bounds of the GuiButton and is released, the event will not fire. If you would like to avoid this limitation, you can use MouseButton2Down and MouseButton2Up; these events are similar but will fire whenever the user presses their right mouse button down or up, respectively.


MouseButton2Down

This event fires when the user presses their right mouse button down on the GuiButton.

For an event requiring the user to press and release their right mouse on a GuiButton in order for the event to fire, consider using MouseButton2Click.

Parameters

The mouse's X screen coordinate in pixels.

The mouse's Y screen coordinate in pixels.


MouseButton2Up

This event fires when the user releases their right mouse button off of the GuiButton.

For an event requiring the user to press and release their right mouse on a GuiButton in order for the event to fire, consider using MouseButton2Click.

Parameters

The mouse's X screen coordinate in pixels.

The mouse's Y screen coordinate in pixels.