Skip navigation
kkirk69
Currently Being Moderated

Modify Window when checkbox clicked.

May 2, 2012 5:02 PM

Tags: #cs3 #checkbox

InDesign 3 (5.0)

ScriptUI (Javascript) on XP box.

 

Trying to get a Window to show more controls when a checkbox is clicked and then hiding them when it is unchecked.

 

I've tried creating the extra controls at creation and then hiding them but this of course doesn't redraw the window. I would prefer to have the window redraw and the layout manager control the position of the controls as they are added or taken away. Then I don't have large empty spaces in my window when the extra controls are not shown.

 

#target "InDesign-5.0";

#targetengine "session";

 

main();

 

function main(){

 

                    var myWindow = new Window('palette', "Signs");

                    myWindow.alignChildren = "left";

                    var buttonGroup = myWindow.add('group');

                              var makeSignsButton = buttonGroup.add('button', undefined, "Make Signs");

                              makeSignsButton.alignment = "left";

                    var printGroup = myWindow.add('panel', undefined, "Print Signs");

                              printGroup.orientation = "row";

                              var advancedCheck = printGroup.add('checkbox', undefined, "Advanced");

                              var allRadio;

                              var currWeekRadio;

                              var nextWeekRadio;

                              var printSignsButton = printGroup.add('button',undefined, "Print Signs");

 

                    advancedCheck.onClick = function(){

                                                  if (advancedCheck.value == true){

                                                                                 allRadio = printGroup.add('radiobutton', undefined, "All");

                                                                                 currWeekRadio = printGroup.add('radiobutton', undefined, "Current Week");

                                                                                 nextWeekRadio = printGroup.add('radiobutton', undefined, "Next Week");

                                                  }

                                                  if (advancedCheck.value ==false){

                                                                                 printGroup.remove("allRadio");

                                                                                 printGroup.remove("currWeekRadio");

                                                                                 printGroup.remove("nextWeekRadio");

                                                                                 printGroup.remove("advancedCheck");

                                                  }

                              }// end"advancedCheck.onClick"

 

                    makeSignsButton.onClick = function(){

                                                  var confirmWindow = confirm("Do you want to make signs","Confirm Make Signs");

 

                                                  myWindow.close();

 

                    }// end makeSignsButton onClick event handler.

                    printSignsButton.onClick = function(){

                                                  var printConfirm = confirm("Do you want to print signs?","Print Confirm");

                                                  if (printConfirm == false){

                                                                      return;

                                                  }

                    }// end "printSigns" onClick callback

                    myWindow.show();

}//end function "main"

 
Replies
  • Currently Being Moderated
    May 2, 2012 5:22 PM   in reply to kkirk69

    After you change the window layout, add myWindow.layout.layout(true) to

    invoke the layout manager.

     

    Ariel

     
    |
    Mark as:
  • Currently Being Moderated
    May 2, 2012 5:43 PM   in reply to kkirk69

    (You've got an error there: to remove a child item you don't need the

    quotes.)

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points