0 Replies Latest reply on Jun 11, 2014 9:37 PM by creativejoan0425

    Dropdown List with Submenu?

    creativejoan0425 Level 1

      Hi, I have a dialog with dropdown list, my dropdown name get from a desktop folder called Testing, and since my dropdown list are too long, can dropdown make a submenu like below?

       

      qqqq.jpg

      Here is my script:

       

      main();

       

       

      function main(){

       

       

        var myObject;

        //Make certain that user interaction (display of dialogs, etc.) is turned on.

        //app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

        if(app.documents.length > 0){

        if(app.selection.length > 0){

        switch(app.selection[0].constructor.name){

                      case "TextFrame":

                      case "Character":

                      case "Word":

                      case "TextStyleRange":

                      case "Line":

                      case "Paragraph":

                      case "TextColumn":

       

       

                      case "Text":

                      case "Cell":

                      case "Column":

                      case "Row":

                      case "Table":

       

       

                      alert("Please insert a insert point, and try again!");

                      exit();

                      break;

       

       

        case "InsertionPoint":

        myDisplayDialog();

       

       

        break;

        default:

        //Something was selected, but it wasn't a text object, so search the document.

        //myFindChangeByList(app.documents.item(0));

                          //alert("Nothing Selected, Please Select Text Frame or Text.");

        }

        }

       

       

        else{

        //Nothing was selected, so simply search the document.

                  //myFindChangeByList(app.documents.item(0));

                  alert("Nothing Selected, Please Select Text Frame or Text.");

        }

        }

        else{

        alert("No documents are open. Please open a document and try again.");

        }

      }

      function myDisplayDialog(){

        var myObject;

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

        with(myDialog.dialogColumns.add()){

        with(dialogRows.add()){

        with(dialogColumns.add()){

        staticTexts.add({staticLabel:"Search Range:"});

        }//end of with(dialogColumns.add())

        var mySearchButtons = radiobuttonGroups.add();

        with(mySearchButtons){

        radiobuttonControls.add({staticLabel:"All Opened Document   ", checkedState:true});

        radiobuttonControls.add({staticLabel:"Current Document"});

        } //end of with(mySearchButtons)

             

             

      //  New Add 20140518 (Line 84 to 103) ----------------------------------------------------------------------------------------- ------------------

        with(dialogColumns.add()){

        with(borderPanels.add()){

        staticTexts.add({staticLabel:"Choose:"});

        var myPDFOptionButtons = radiobuttonGroups.add();

        with(myPDFOptionButtons){

        radiobuttonControls.add({staticLabel:"Option A", checkedState:true});

        radiobuttonControls.add({staticLabel:"Option B"});

                          }// end of with(myPDFOptionButtons)

                          }//end of borderPanels

      //  New Add 20140604 Job Dictionary function  ----------------------------------------------------------------------------------------- ------------------

             with(dialogRows.add()){

                      staticTexts.add({staticLabel:"Please Choose: "});

                     var myFileName = "";

                     var myFileName2 = "";

                     var myFileName3 = "";

                     var myFileName4 = "";

                     var myFileName5 = "";

                  

                     var myDictPath =  new File('~desktop/Testing/A-E');

              //       var myDictPath2 =  new File('~desktop/Testing/F-J');

                 //    var myDictPath3 =  new File('~desktop/Testing/K-O');

                  //   var myDictPath4 =  new File('~desktop/Testing/P-T');

                   //  var myDictPath5 =  new File('~desktop/Testing/P-T');

       

                     var myDictFolder = Folder(myDictPath);

                     var myDicttext = myDictFolder.getFiles();

                      for (var i = 0; i < myDicttext.length; i++) {

                      var sourceChild = myDicttext[i];

                      if (sourceChild instanceof File && sourceChild.name.match(/\.txt$/i)) {

                      myFileName += " " +sourceChild.name.replace(/\.txt$/i, "");

        }//end of if

              }//end of loop

       

       

                  var myDictNameList = myFileName.split(" ");

                 //var myDictValue= [1,2,3];

                  var myDropdowns = dropdowns.add({stringList:myDictNameList, selectedIndex:0});

                //  myDropdowns.unshift("- Select Preset - ");

                 

       

       

              }//end of with(dialogRows.add()) Line 98

       

       

      //  New Add 20140604 Job Dictionary function  ----------------------------------------------------------------------------------------- ------------------

                 with(dialogRows.add()){

                      staticTexts.add({staticLabel:"Highlight Color: "});

                      var myColor = ["Gold", "Yellow", "Black"];

                      var myColorValue = [UIColors.GOLD, UIColors.YELLOW, UIColors.BLACK];

                      var myDropdowns = dropdowns.add({stringList:myColor, selectedIndex:0});

        }//end of with(dialogRows.add()) Line 117

          }//end of dialogColumns Line 87

            

      //  New Add 20140518 (Line 84 to 103) ----------------------------------------------------------------------------------------- ------------------

          }//end of dialogRows Line 75

          }//end of dialogColumns Line 74

      var myResult = myDialog.show();

        if(myResult == true){

        switch(mySearchButtons.selectedButton){

        case 0:

                      myObject = app.documents.everyItem();

        break;

        case 1:

                  myObject = app.documents.item(0);

       

       

        break;

        }//end of switch

      //---------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------

      switch(myPDFOptionButtons.selectedButton){

        case 0:

                  alert("Option A");

                break;

        case 1:

                  alert("Option B");

          break;

        }//end of switch

        myDialog.destroy();

        }//end of if my result

        else{

        myDialog.destroy();

        }//end of else

      }// end of function