Change size of a button in a scripts ui?

danell
Posts: 35
Joined: Mon Dec 12, 2016 6:32 am
Been thanked: 1 time

Change size of a button in a scripts ui?

#1

Post by danell » Sat Apr 20, 2019 12:32 pm

Are there any way to change the size of buttons inside a scripts ui?
The only info I have found is IconSize of a button but that's not it.
The other thing is the geometry size of the UI itself, but my buttons gets added outside the AddWindows function and becomes bigger than my set geometry size.

User avatar
AndrewHazelden
Fusionator
Posts: 1259
Joined: Fri Apr 03, 2015 3:20 pm
Location: West Dover, Nova Scotia, Canada
Been thanked: 28 times
Contact:

Re: Change size of a button in a scripts ui?

#2

Post by AndrewHazelden » Sat Apr 20, 2019 1:08 pm

danell wrote:
Sat Apr 20, 2019 12:32 pm

Are there any way to change the size of buttons inside a scripts ui?

If you know the size of the UI Manager button in advance you could add this tag to help define its minimum dimensions. (This is used in addition to defining the ui icon size.)

MinimumSize = {150,32},


This post by Midgardsormr has some tips on UI manager based exact sizing of GUI elements with the "FixedSize" tag:

viewtopic.php?p=16848#p16848


And this post by Midgardsormr mentions the use of the window:RecalcLayout() method which helps relayout and adjust the spacing of controls in a window in cases where you've added new elements dynamically after the initial window creation period:

viewtopic.php?p=16849#p16849


Also, as an extra note, you can change the icon attached to a button dynamically using this type of code:

Code: Select all

    -- Toggle the center button to a new icon
    itm.CenterIconButton:SetIcon(ui:Icon{
      ID = "CenterIcon", 
      File = iconFolderPath .. "new-icon.png",
    })

If you want to see several icons being added to a GUI dynamically you can install the "UI Manager Lua & Python Examples" atom in Reactor and then open the script that is accessible here:

Reactor:/Deploy/Scripts/Comp/UI Manager/HTML Code Editor/HTML Code Editor.lua


danell
Posts: 35
Joined: Mon Dec 12, 2016 6:32 am
Been thanked: 1 time

Re: Change size of a button in a scripts ui?

#3

Post by danell » Sat Apr 20, 2019 1:14 pm

I tried MaximumSize and that did the trick for me!
Thanks!