FORUMS: list search recent posts

Radio Button Handling - ExtendScript

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Krishna Moorthy
Radio Button Handling - ExtendScript
on Dec 11, 2016 at 10:53:54 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!

Return to posts index

Walter Soyka
Re: Radio Button Handling - ExtendScript
on Dec 12, 2016 at 5:45:17 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.grp.minimumSize = myPanel.grp.size;
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){;;


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!");


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

Return to posts index

Krishna Moorthy
Re: Radio Button Handling - ExtendScript
on Dec 14, 2016 at 12:41:05 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!

Return to posts index

Krishna Moorthy
Re: Radio Button Handling - ExtendScript
on Dec 14, 2016 at 12:55:42 pm


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!

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 All Rights Reserved