Skip to main content
Known Participant
September 29, 2023
Question

How do I make the button size dynamic to the panel size

  • September 29, 2023
  • 0 replies
  • 123 views
function myScript(thisObj) {
    function myScript_buildUI(thisObj) {
        var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "Dockable Elements", undefined, { resizeable: true });

        var res = "group{orientation:'row',\
           buttonGroup: Group{orientation:'row',\
            buttonOne: Button{text:'Wiggle'},\
            buttonTwo: Button{text:'Random'},\
            buttonThree: Button{text:'ReRe'},\
        },\
        }";

        myPanel.grp = myPanel.add(res);

        // Function to handle the 'Wiggle' button click
        function onWiggleButtonClick() {
           
        }

        // Function to handle the 'Random' button click
        function onRandomButtonClick() {
            
        }

        function onReReButtonClick() {
            
        }


        // Add onclick functions to the buttons
        myPanel.grp.buttonGroup.buttonOne.onClick = onWiggleButtonClick;
        myPanel.grp.buttonGroup.buttonTwo.onClick = onRandomButtonClick;
        myPanel.grp.buttonGroup.buttonThree.onClick = onReReButtonClick;

        myPanel.layout.layout(true);

        return myPanel;
    }

    var myScriptPal = myScript_buildUI(thisObj);

    if (myScriptPal != null && myScriptPal instanceof Window) {
        myScriptPal.center();
        myScriptPal.show();
    }
}

myScript(this);

I got this from Chat GPT because i don't know much about scripting, I want the buttons to resize horizontally only

This topic has been closed for replies.