Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

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

Explorer ,
Sep 29, 2023 Sep 29, 2023
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

TOPICS
Expressions , Scripting
126
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation