3 Replies Latest reply on May 3, 2012 10:19 AM by kkirk69

    Modify Window when checkbox clicked.

    kkirk69

      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"