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

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

Explorer ,
Sep 29, 2023 Sep 29, 2023

Copy link to clipboard

Copied

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

Views

57

Translate

Translate

Report

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