TextButton¶
TextButton is a class inherited from BaseButton, compared to its ancestor, TextButton provides basic text support on top of a button. You can add text to the button either by using string
or Fusion.Value
.
Usage¶
TextButton can be created by calling Lydie.Components.Controls.TextButton
:
local textState = Fusion.Value("Hello world!")
Lydie.Components.Controls.TextButton {
Size = UDim2.fromOffset(200, 40),
Text = textState,
OnClickDown = function(),
textState:set("Hello world??")
end,
OnClick = function() -- (1)!
textState:set("Hello world!")
end,
}
OnClick
function will be invoked whenInputEnded
is fired and its input type matches eitherEnum.UserInputType.MouseButton1
orEnum.UserInputType.Touch
. Due to how input events work in Roblox, input will sink no matter what. You should ensure the user is clicking the button before doing any further processing. See BaseButton.luau:69.
Properties¶
Note
While being inherited from BaseButton, TextButton does not allow using the Fusion.Children
to insert children as it will be used to insert the text label instead.
Name | Description | Required | Default |
---|---|---|---|
BackgroundColor |
Background color of the button | Scheme.GetAnimated(Scheme.Color.Text.Primary) |
|
BackgroundOpacity |
Background opacity of the button | 0.85 |
|
ForegroundColor |
Foreground color of the button, used to color the text | BackgroundColor or Scheme.GetAnimated(Scheme.Color.Text.Primary) |
|
Text |
The text string of the button. | nil |
|
RoundedValue |
The radius of the 4 corners | Constants.RoundedValues[8] |
|
LayoutOrder |
The layout order of the button, used in a UIListLayout /UIGridLayout |
0 |
|
ZIndex |
The Z index of the button, used to show hierarchy of the button. | NaN |
|
AnchorPoint |
The location of the anchor point, defined in Vector2 |
Vector2.new(0, 0) |
|
Position |
The relative position of the button | UDim2.fromScale(0, 0) |
|
Size |
The size of the button | UDim2.fromOffset(200, 50) |
Functions¶
Name | Description | Required |
---|---|---|
OnClickDown: () -> () |
A function invoked when MouseButton1Down is fired, where a user clicks the button and does not release |
|
OnClick: () -> () |
A function invoked when InputEnded is fired with matching input types Enum.UserInputType.MouseButton1 or Enum.UserInputType.Touch , where a user clicks the button and releases |