PluginToolbarButton

Show Deprecated
Not Creatable

A PluginToolbarButton is an object created by the PluginToolbar:CreateButton() function. It allows the user to initiate a single, one-off action in Roblox Studio through the Click event. Pictured below are three PluginToolbarButtons. From left to right: the default, hover and pressed states. The hovered button in the center shows tooltip text, which is the 2nd argument passed to PluginToolbar:CreateButton().

Three PluginToolbarButtons rendered on a PluginToolbar titled "Three Wise Monkeys"

Behavior

When pressed, the Click event fires. A button will also remain in the pressed state, which may be set manually using SetActive. Upon plugin activation (Plugin:Activate()), buttons in all other PluginToolbars will be toggled off. If all buttons in a toolbar are off, the toolbar's plugin is deactivated (Plugin:Deactivate()).

When the game viewport is not visible, buttons will be disabled as if their Enabled property were false. Disabled buttons are desaturated and do not respond to user clicks. By setting ClickableWhenViewportHidden to true, you can allow plugin buttons to remain clickable (such as during script editing).

History

  • Prior to an update released in January 2019, this class was simply known as "Button". This was changed to reduce confusion with similarly named in-game UI element classes, such as TextButton.

Summary

Properties

Determines whether the button can be clicked when the game viewport is hidden, such as while editing a script in a different Studio tab.

NOT REPLICATED

Determines whether the button is clickable in general.

NOT REPLICATED
NOT REPLICATED

Events


Fires when the user presses and releases their cursor on the button.

Methods

SetActive(active: boolean): nil  


Properties

ClickableWhenViewportHidden

Not Replicated

ClickableWhenViewportHIdden determines whether a PluginToolbarButton may be clicked while the game viewport is hidden, such as when a Script is being edited in another tab. In the image below, various plugin toolbar buttons are visible. Some are enabled as a result of this property being true, such as the Localization Tools button.

Various plugin toolbar buttons visible while a Script is being edited, causing the game viewport to be hidden. Some of the buttons are enabled due to this property being true.

Typically, this property is good to enable if an action triggered by a plugin button's Click event doesn't occur in the game world (Workspace). For example, a button that opens a widget should have this property be true, as showing a widget is visible to the user even if the game view isn't visible.

Enabled

Not Replicated

Enabled determines whether a button is clickable in general. When this property is false, the button will be greyed out and unclickable, preventing the user from firing the Click event. Buttons are enabled by default.

Plugins should disable their buttons when the button action isn't relevant in the current context. For example, a plugin button that assigns random colors to selected should not be enabled when the selection contains no parts. See the code samples for more information.

See also:

Not Replicated

Events

Click

Plugin Security

Click fires when the PluginToolbarButton is pressed and released by the user.

Clicking a PluginToolbarButton causes the state of the button to toggle. Call SetActive to manually set the state of the button.


Code Samples

PluginToolbarButton.Click

1assert(plugin, "This script must be run as a plugin")
2
3local toolbar = plugin:CreateToolbar("Hello World Plugin Toolbar")
4local pluginToolbarButton = toolbar:CreateButton(
5 "Print Hello World",
6 "Click this button to print Hello World!",
7 "rbxassetid://133293265"
8)
9
10local function onClick()
11 print("Hello, world")
12end
13
14pluginToolbarButton.Click:Connect(onClick)

Methods

SetActive

Plugin Security

Parameters

active: boolean

Returns