1 Reply Latest reply on Oct 16, 2014 1:56 PM by rob day

    Why can't I get the value of "checkedState" in ScriptUI?

    Crundo

      I found I can't get checkedState's value recently, and anybody can help me?

       

      The snippet script is following:

       

      #target "InDesign-8.0"

      main();

       

       

      function main(){

          myInterFace();

          myTeardown();

      }

       

       

      function myInterFace(){

          //<fragment>

          var myDialog = app.dialogs.add({name:"Testing", canCancel:true});

          with(myDialog){

              //Add a dialog column.

              with(dialogColumns.add()){

                  with(checkboxControls.add()){

                      staticLabel = "Facing Pages";

                      checkedState = true;

                      minWidth = 140;

                      }

                  }

              }

        if(myDialog.show() == true){

              var mycheckboxControl = app.dialogs.item(0).dialogColumns.item(0).checkboxControls.item(0);

              var pageMarginSetting = new Array;

              pageMarginSetting.push(mycheckboxControl.checkedState);

              alert("testing");

              formattingTemplate(pageMarginSetting);

              myDialog.destroy();

              }

        else{

        myDialog.destroy()

              }

          }

       

       

      function formattingTemplate(pageMarginSetting){

          var myFileNameString = "/C_Test_Template.indd"

          var myDoc = app.documents.add({name:myFileNameString});

          with(myDoc.documentPreferences){

              pageHeight = 280;

              pageWidth = 210;

              pageOrientation = PageOrientation.portrait;

              facingPages = pageMarginSetting[0];

              startPageNumber = 1;

              }

          myDoc.save(File(Folder.desktop + myFileNameString));

          }

      function myTeardown(){

        

          }

        • 1. Re: Why can't I get the value of "checkedState" in ScriptUI?
          rob day Adobe Community Professional & MVP

          Try declaring the checkbox as a variable up in the dialog construction something like this:

           

           

          //====================//

          #target "InDesign-8.0"

           

          main();

          function main(){

              myInterFace();

          }

           

          function myInterFace(){

           

              var myDialog = app.dialogs.add({name:"Testing", canCancel:true});

              with(myDialog){

              

                  //Add a dialog column.

                  with(dialogColumns.add()){

                 

                      //checkbox as variable

                      var myFPCheckbox =checkboxControls.add({staticLabel:"Facing Pages", checkedState:true, minWidth: 140})

                      with(myFPCheckbox){

                          }

                      }

                  }

                 if(myDialog.show() == true){

           

                      var pageMarginSetting = new Array;

                      pageMarginSetting.push(myFPCheckbox.checkedState);

                      alert("testing checkbox result=  "+myFPCheckbox.checkedState);

                      myDialog.destroy();

                  }

            else{

           

                      myDialog.destroy()

               }

          }