Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Radio Button Handling – ExtendScript

  • Radio Button Handling – ExtendScript

    Posted by Krishna Moorthy on December 11, 2016 at 10:53 pm

    The Script UI is simple, 2 radio buttons(say r1 and r2) and a single button(say b1). The function to be done is, if r1 is selected and b1 is pressed, certain function(say f1) should happen and there is no problem. If r2 is selected and then b1 is pressed, in addition to f1 another function should also be done. I’ve tried a if else loop to check which radio button’s value is true and then assigned functions accordingly. But, it doesn’t work correctly. Kindly, help me in handling radio buttons. Hope, I have explained my scenario clearly. Ask if further explanation needed.

    Thank you!

    Krishna Moorthy replied 9 years, 5 months ago 2 Members · 3 Replies
  • 3 Replies
  • Walter Soyka

    December 12, 2016 at 5:45 pm

    Based on your code from a previous post:

    function myScript(thisObj){
    function myScript_buildUI(thisObj){
    var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "myScript", undefined, {resizeable:true});
    if(myPanel != null){
    var res = "group {orientation:'column',\
    grp1: Group {orientation:'row',\
    RadioButton1: RadioButton{text:'1'},\
    RadioButton2: RadioButton{text:'2'},\
    },\
    grp2: Group {\
    finalButton: Button{text:'Make a PIP'}\
    }\
    }";
    myPanel.grp = myPanel.add(res);

    myPanel.layout.layout(true);
    myPanel.grp.minimumSize = myPanel.grp.size;
    myPanel.layout.resize();
    myPanel.onResizing = myPanel.onResize = function () {this.layout.resize();}

    // when finalButton is clicked, call makePIP() and pass the values of RadioButton1 and RadioButton2 from the UI as parameters.
    myPanel.grp.grp2.finalButton.onClick = function () { makePIP(myPanel.grp.grp1.RadioButton1.value, myPanel.grp.grp1.RadioButton2.value);}

    return myPanel;
    }
    }

    var myPal = myScript_buildUI(thisObj);
    if(myPal != null){
    if(myPal instanceof Window){
    myPal.center();
    myPal.show();
    }
    }

    }

    function makePIP(r1, r2) {
    // r1 is the value of RadioButton1 in the UI; r2 is the value of RadioButton2.
    // what this button actually does depends on which value is true.
    if (r1) alert("Radio button 1!");
    if (r2) alert("Radio button 2!");
    }

    myScript(this);

    Walter Soyka
    Designer & Mad Scientist at Keen Live [link]
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    @keenlive   |   RenderBreak [blog]   |   Profile [LinkedIn]

  • Krishna Moorthy

    December 14, 2016 at 12:41 pm

    Hey Walter,

    That’s a great help. Thanks a lot dude. Where can I get the resources related to this. Handling user inputs in extendscript.

    Thanks buddy!

  • Krishna Moorthy

    December 14, 2016 at 12:55 pm

    Walter,

    I have a doubt.
    Copied the above code you posted in a .jsx file and saved it in the scriptsUI folder. It works fine.
    Now, how come the AE know the value of r1 and r2. We didn’t defined or declared them anywhere on the code. Please explain.

    Thank you!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy