4 Replies Latest reply on Jul 14, 2014 9:29 AM by creativejoan0425

    Script UI

    creativejoan0425 Level 1

      If have a button, when click "Button 1",it will pop up second dialog and then click "Button 2", need to pop up third dialog

      but can't pop the third dialog, why?

       

      w = new Window ("dialog", "Test", undefined, {resizeable: true});

      var myText = w.add("edittext", undefined, "", {multiline: true})

      myText.alignment = ["fill", "fill"];

      myText.minimumSize = [300, 30];

      w.location = [55, 140];

      myPrinter = w.add("button", undefined, "Button 1");

       

       

      var w2 = new Window ("dialog");

      w2 .add ("button", undefined, "Button 2");

       

       

      var w3 = new Window ("dialog");

      w3 .add ("button", undefined, "Button 3");

       

       

      myPrinter.onClick = function() {

                 w2.show();

                 }

      w3.onClick = function() {

               w3.show();

      }

      w.show();

        • 1. Re: Script UI
          TᴀW Adobe Community Professional & MVP

          Works fine here:

           

          var i = 0;

          newWindow();

           

          function newWindow(){

               i++;

               var w = new Window ("dialog", "Window " + i);

               var b = w.add("button", undefined, "New Window");

               b.onClick = newWindow;

               w.onShow = function(){

                   w.location.x = w.location.y = 100 + i *30;

               }

               w.show();

          }

          • 2. Re: Script UI
            creativejoan0425 Level 1

            Thx but that not what I want

            each button I click have different action to do

             

            yr script seem click the button the action is the same

            • 3. Re: Script UI
              milligramme Level 3

              var w2 = new Window ("dialog");

              w2 .add ("button", undefined, "Button 2"); /// <= HERE

               

               

              var w3 = new Window ("dialog");

              w3 .add ("button", undefined, "Button 3");

               

               

              myPrinter.onClick = function() {

                        w2.show();

                        }

              w3.onClick = function() { /// <= AND HERE

                      w3.show();

              }

              w.show();

               

              Hi, your code is not pointed Button2 ,

               

              var button2 = w2 .add ("button", undefined, "Button 2");
              
              

               

              set variable and

               

              button2.onClick = function() {...}
              
              


              OR


               

              w2 .add ("button", undefined, "Button 2", {name: "Button 2"});

               


              set name and call 'Button 2' element


               

              w2['Button 2'].onClick = function() {...}

               


              thank you

              • 4. Re: Script UI
                creativejoan0425 Level 1

                I fix my button to set variable but when I click button2 can response the action print, is it something wrong?

                       var w1 = new Window ('dialog', 'Test', undefined, {resizeable: true});

                       var myText = w1.add('edittext', undefined, 'TEST', {multiline: true});

                            myText.alignment = ['fill', 'fill']

                            myText.minimumSize = [300, 30]

                            w1.location = [55, 140]

                       var myButton1 = w1.add('button', undefined, 'Button 1')

                        var w2 = new Window ('dialog');

                        var panel1 = w2.add ('panel');

                        var panel2 = w2.add ('Group');

                        var myButton2 = panel2.add('button', undefined, 'myButton2');

                                                 panel2.alignChildren ='right';

                myButton1.onClick = function() {

                    w2.show();

                    }

                myButton2.onClick = function() {

                    app.activeDocument.print();

                   }

                 

                 

                w1.show();