3 Replies Latest reply on Jun 11, 2014 9:03 AM by Larry G. Schneider

    Dropdown

    Ferrarezzi

      Hello friends.

       

      I wonder why I can not change the desired text, please someone tell what is wrong in this script?

       

      #target illustrator

       

      var w = new Window ("dialog");

      var myDropdown = w.add ("dropdownlist", undefined, ["one", "two", "three"]);

      myDropdown.selection = 0;

      var Ok = w.add ("button", undefined, "OK");

      w.show ();

       

      Ok.onClick=function(){

      var item=myDropdown.selection.text

              var myMATERIAL = item;

              var myF_MATERIAL = sourceDoc.textFrames.getByName("MATERIAL");

              myF_MATERIAL.contents=myMATERIAL       

              }

        • 1. Re: Dropdown
          CarlosCanto Adobe Community Professional & MVP

          see my comments

           

          #target illustrator
          
          
          var sourceDoc = app.activeDocument; // added document reference
          var w = new Window ("dialog");
          var myDropdown = w.add ("dropdownlist", undefined, ["one", "two", "three"]);
          myDropdown.selection = 0;
          var Ok = w.add ("button", undefined, "OK");
          
          
          
          Ok.onClick=function(){
             
          var item=myDropdown.selection.text
                  var myMATERIAL = item;
                  var myF_MATERIAL = sourceDoc.textFrames.getByName("MATERIAL");
                  myF_MATERIAL.contents=myMATERIAL     
                  app.redraw(); // added to refresh the sceen
                  }
             
              w.show (); // moved to the bottom
          
          • 2. Re: Dropdown
            Ferrarezzi Level 1

            Thank you so much Carlos, I am now starting to work with UI so whenever I make silly mistakes, thank you really.

            • 3. Re: Dropdown
              Larry G. Schneider Adobe Community Professional & MVP

              Look for Peter Kahrel's excellent ScriptUI manual (scriptui-2-2.pdf)