Skip to content

Commit

Permalink
Button Size argument.
Browse files Browse the repository at this point in the history
Added a size argument to button widgets which sets the minimum size of the Button, allowing for full width buttons. The text is also centered within the button.
  • Loading branch information
SirMallard committed Sep 4, 2024
1 parent fd0473b commit 1e78042
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/WidgetTypes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export type SeparatorText = Widget & {
export type Button = Widget & {
arguments: {
Text: string?,
Size: UDim2?,
},
} & Clicked & RightClicked & DoubleClicked & CtrlClicked & Hovered

Expand Down
5 changes: 4 additions & 1 deletion lib/widgets/Button.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility)
hasChildren = false,
Args = {
["Text"] = 1,
["Size"] = 2,
},
Events = {
["clicked"] = widgets.EVENTS.click(function(thisWidget: Types.Widget)
Expand All @@ -30,9 +31,10 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility)
Button.BackgroundColor3 = Iris._config.ButtonColor
Button.BackgroundTransparency = Iris._config.ButtonTransparency
Button.AutoButtonColor = false
Button.AutomaticSize = Enum.AutomaticSize.XY

widgets.applyTextStyle(Button)
Button.AutomaticSize = Enum.AutomaticSize.XY
Button.TextXAlignment = Enum.TextXAlignment.Center

widgets.applyFrameStyle(Button)

Expand All @@ -53,6 +55,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility)
Update = function(thisWidget: Types.Button)
local Button = thisWidget.Instance :: TextButton
Button.Text = thisWidget.arguments.Text or "Button"
Button.Size = thisWidget.arguments.Size or UDim2.fromOffset(0, 0)
end,
Discard = function(thisWidget: Types.Button)
thisWidget.Instance:Destroy()
Expand Down
1 change: 1 addition & 0 deletions lib/widgets/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ return function(Iris: Types.Internal)
thisInstance.TextColor3 = Iris._config.TextColor
thisInstance.TextTransparency = Iris._config.TextTransparency
thisInstance.TextXAlignment = Enum.TextXAlignment.Left
thisInstance.TextYAlignment = Enum.TextYAlignment.Center
thisInstance.RichText = Iris._config.RichText
thisInstance.TextWrapped = Iris._config.TextWrapped

Expand Down

0 comments on commit 1e78042

Please sign in to comment.