AtomicButton
The foundational model for all UI button components in the game. On top of the AtomicPane base, it adds interaction states such as hover, press, selected, and enabled. It also provides events for these interactions. Anything can be a button with this class, it will automatically create a TextButton if one does not already exist (must be named "Sensor" and a direct child of the Gui instance).
Inherits from AtomicPane
A VS Code snippet for creating AtomicButtons quickly is included with the Git repository.
NOTE
The source GUI objects should be located in
ReplicatedStorage.GuiTemplates, or Assets.GuiTemplates if using an
Enclave package. They can be of any GuiObject type.
Basic usage
local AtomicButton = shared("AtomicButton") ---@module AtomicButton
local ExampleButton = setmetatable({}, AtomicButton)
ExampleButton.__index = ExampleButton
ExampleButton.ClassName = "ExampleButton"
function ExampleButton:_draw()
local alpha = self._springs.Alpha.Position
self.Gui.Visible = alpha < 0.999
end
function ExampleButton.new(parent: Instance)
local self = setmetatable(AtomicButton.new("ExampleButtonTemplate", {}), ExampleButton)
self:SetVisible(false, true)
self.Gui.Parent = parent
return self
end
return ExampleButton
Properties
Activated
Fires when the button is activated or deactivated.
Hovered
Fires when the button is hovered or unhovered.
Enabled
Fires when the button is enabled or disabled.
Pressed
Fires when the button is pressed or unpressed.
Selected
Fires when the button is selected or unselected.
Functions
new
ConstructorAtomicButton.new(template: string | Instance,--
The name of a GuiObject in ReplicatedStorage.GuiTemplates or an existing instance to use as the button's Gui.
instanceKeys: table--
A mapping of instance names to keys for quick access
) → ()Creates a new AtomicButton based on the template key or existing frame. Instances are mapped based on a simple descendants search, so unique names are required for consistency.
Activate
AtomicButton:Activate() → ()Manually activates the button without requiring the user to click it.
SetPressed
AtomicButton:SetPressed(pressed: boolean--
The new pressed state
) → ()Manually sets the pressed state of the button without requiring the user to click it.
SetHovered
AtomicButton:SetHovered(hovered: boolean) → ()Sets the hovered state of the button
SetSelected
AtomicButton:SetSelected(selected: boolean) → ()Sets the selected state of the button
SetEnabled
AtomicButton:SetEnabled(enabled: boolean) → ()Sets the enabled state of the button
IsEnabled
AtomicButton:IsEnabled() → boolean--
Whether the button is enabled
IsHovered
AtomicButton:IsHovered() → boolean--
Whether the button is hovered
IsPressed
AtomicButton:IsPressed() → boolean--
Whether the button is pressed
IsSelected
AtomicButton:IsSelected() → boolean--
Whether the button is selected