Creative Communities of the World Forums

The peer to peer support community for media production professionals.

  • Posted by Steve Sierra on May 8, 2017 at 8:05 am

    Hi to all,

    I am having a hard time with radio buttons for my UI…
    Using the “res” method, I have two radio button for A and B settings on a few properties (position and rotation).

    I later use if statements to set these values on my properties in the main function.
    My problem these if statements seem to not do what they are supposed to do and make the script ignore the rest of the code.
    This happens wherever I place them, even right after my position and rotation variables are declared.
    The weird part, is I put alerts in the if statements, and they work fine ! (which means my position and rotation variables lose their reference ?)

    Can someone please help me figure out how to use the radio buttons in the main script ?

    Many thanks in advance ????
    Here’s a resumed version of my script :

    {
    function myScript(thisObj) {
    function myScript_buildUI(thisObj) {
    var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "MAGNIFY MASK", [0, 0, 300, 300]);

    res = "group{orientation:'column', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\
    myGroup: Group{orientation:'column', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\
    myStaticText: StaticText{text:'Magnify Mask'},\
    HorRadioButton: RadioButton{text:'Horizontal'},\
    VertRadioButton: RadioButton{text:'Vertical'},\
    myStaticTextTwo: StaticText{text:'Copies ?'},\
    CopiesEditText: EditText{text:'1'},\
    myStaticTextThree: StaticText{text:'Lines ?'},\
    LineCheckbox: Checkbox{text:'Lines ?'},\
    LineStaticText: StaticText{text:'Number of Lines ?'},\
    LineEditText: EditText{text:'1'},\
    myStaticTextFour: StaticText{text:'Bevel ?'},\
    BevelCheckbox: Checkbox{text:'Bevel ?'},\
    myStaticTextFive: StaticText{text:'Blur ?'},\
    BlurCheckbox: Checkbox{text:'Blur ?'},\
    myButton: Button{text:'Go !'},\
    },\
    }"

    // Adds resource string to panel
    myPanel.grp = myPanel.add(res);

    // default
    myPanel.grp.myGroup.HorRadioButton.value = true;

    // Assign function to UI elements

    myPanel.grp.myGroup.myButton.onClick = function (){

    var UIgroup = myPanel.grp.myGroup;
    ................
    .......CODE......
    .................

    if(UIgroup.HorRadioButton.value == true){
    alert("OK");
    mRot.setValue(180);
    mPosY.setValue(cHeight/10);
    mPosX.setValue(-100);
    };

    if(UIgroup.VertRadioButton.value == true){
    alert("no");
    mRot.setValue(-90);
    mPosY.setValue(100);
    mPosX.setValue(cWidth/10);
    };

    ................
    .......CODE IGNORED......
    .................

    }
    };

    // Setup panel sizing and make panel resizable
    myPanel.layout.layout(true);
    myPanel.grp.minimumSize = myPanel.grp.size;
    myPanel.layout.resize();
    myPanel.onResizing = myPanel.onResize = function () {this.layout.resize();}

    return myPanel;
    }

    // Build script panel
    var myScriptPal = myScript_buildUI(thisObj);

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

    // Execute script
    myScript(this);
    }

    Steve Sierra replied 9 years ago 2 Members · 4 Replies
  • 4 Replies
  • Steve Sierra

    May 8, 2017 at 12:54 pm

    Hi again,

    I’ve come upon a new problem while learning UI building…

    I’m just trying to have a simple comp created… but it seems my width and height variables block everything and I can’t figure out why. All the other variables work (the ignored line of code works fine).

    Thanks for any help !
    😉

    {
    function myScript(thisObj) {
    function myScript_buildUI(thisObj) {
    var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "NEW COMP", [0, 0, 600, 600]);

    res = "group{orientation:'column', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\
    compPanel: Panel{text:'Comp Settings', orientation:'column', alignChildren:['fill', 'fill'],\
    nameGroup : Group{text:'Comp Name', orientation:'row', alignChildren:['left', 'fill'],\
    cName: EditText{text:'New Comp'},\
    cNameStaticText: StaticText{text:'Comp Name'},\
    },\
    widthGroup : Group{text:'Comp Width', orientation:'row', alignChildren:['left', 'fill'],\
    cWidth: EditText{text:'1920'},\
    cWidthStaticText: StaticText{text:'Comp Width'},\
    },\
    heightGroup : Group{text:'Comp Height', orientation:'row', alignChildren:['left', 'fill'],\
    cHeight: EditText{text:'1080'},\
    cHeightStaticText: StaticText{text:'Comp Height'},\
    },\
    pixelGroup : Group{text:'Comp PixAsp', orientation:'row', alignChildren:['left', 'fill'],\
    cPA: EditText{text:'1'},\
    cPAStaticText: StaticText{text:'Comp PixelAspect'},\
    },\
    durGroup : Group{text:'Comp Dur', orientation:'row', alignChildren:['left', 'fill'],\
    cDur: EditText{text:'5'},\
    cDurStaticText: StaticText{text:'Comp Duration'},\
    },\
    FPSGroup : Group{text:'Comp FPS', orientation:'row', alignChildren:['left', 'fill'],\
    cFPS: EditText{text:'25'},\
    cFPSStaticText: StaticText{text:'Comp FPS'},\
    },\
    },\
    buttonGroup: Group{text:'Go', orientation:'column', alignChildren:['fill', 'fill'],\
    myButton: Button{text:'Make New Comp'},\
    },\
    }"

    // Adds resource string to panel
    myPanel.grp = myPanel.add(res);

    // Defaults

    // Assign function to UI elements
    myPanel.grp.buttonGroup.myButton.onClick = function (){

    app.beginUndoGroup("NewComp");

    var ncName = myPanel.grp.compPanel.nameGroup.cName.text;
    var ncWidth = myPanel.grp.compPanel.widthGroup.cWidth.text;
    var ncHeight = myPanel.grp.compPanel.heightGroup.cHeight.text;
    var ncPixel = myPanel.grp.compPanel.pixelGroup.cPA.text;
    var ncDuration = myPanel.grp.compPanel.durGroup.cDur.text;
    var ncFPS = myPanel.grp.compPanel.FPSGroup.cFPS.text;

    var newComp = app.project.items.addComp(ncName, ncWidth, ncHeight, ncPixel, ncDuration, ncFPS);
    //var newComp = app.project.items.addComp(ncName, 1000, 1000, ncPixel, ncDuration, ncFPS);

    app.endUndoGroup();
    }
    // Setup panel sizing and make panel resizable
    myPanel.layout.layout(true);
    myPanel.grp.minimumSize = myPanel.grp.size;
    myPanel.layout.resize();
    myPanel.onResizing = myPanel.onResize = function () {this.layout.resize();}

    return myPanel;
    }

    // Build script panel
    var myScriptPal = myScript_buildUI(thisObj);

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

    // Execute script
    myScript(this);
    }

  • Dan Ebberts

    May 8, 2017 at 1:06 pm

    I think you need to convert the width, height, pixelAspectRatio, duration and frameRate variables from text to numbers with parseInt() and/or parseFloat().

    Dan

  • Steve Sierra

    May 8, 2017 at 1:23 pm

    Hi Dan,

    Thanks ! That works in deed.

    I only need to parse width and height. It seems pixelAspectRatio, duration and frameRate are automatically read as numbers…
    Is there a special rule for this ?

    Is there a similar rule I am not applying with my radio buttons ?

    Thanks again for your time.

    Cheers !

  • Steve Sierra

    May 8, 2017 at 5:39 pm

    Ok,

    I found my error for the radio buttons… I had to redefine my variables for they were sliders and I had added other effects in the meantime.

    So there was no error with the radio buttons ????

    Cheers !

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