7 Replies Latest reply on Jul 19, 2016 9:07 PM by daitranthanhoa

    How close a Dialog?

    daitranthanhoa Level 1

      Current i show a dialog of Indesign:

      oIndd.DoScript ( "var range = new Window (" "dialog" "," "test" ", [200, 200 680, 325] {resizeable: false}); this.palette.show ();", 1246973031)

      Can i call a other script to close that dialog ?

        • 1. Re: How close a Dialog?
          LSH_246 Level 1

          Hi daitranthanhoa,

           

          Take a look in the object model viewer at the documentation for the Window constructor. You can find it in the object model viewer by choosing "ScriptUI Classes" under the Browser area, then "Constructor" under Types, then "Window (type, title, bounds, properties)" under Properties and Methods.

           

          You'll find documented there that creating a Window with the type "dialog" (as you do in your script) creates a modal window - control won't return to your script until the user closes the dialog.

           

          Instead, create is at type "palette".

           

          Your script is also missing some commas and doesn't compile. I'm also not sure what context you're calling the script from. Here's a sample script that works:

           

          var range = new Window ("palette","test", [200, 200, 680, 325], {resizeable: false}); 
          // show the palette
          range.show();
          
          // do whatever you need to do
          alert("Hellow world!");
          
          // close the palette
          range.close(); // can also hide() if you want the palette to retain its state
          

           

          Lawrence

          • 2. Re: How close a Dialog?
            Loic.Aigon Adobe Community Professional

            Getting an external script to close a dialog from a different one implies to have them evolve in the same script engine.

             

            Script 1:

            #targetengine "myWindow"

            //The window object needs to be globally exposed somehow

            var w = new Window();

             

            Script 2:

            #targetengine "myWindow"

            w.close();

             

             

            HTH

            Loic

            • 3. Re: How close a Dialog?
              daitranthanhoa Level 1

              i want close a dialog , not palette.

               

              • 4. Re: How close a Dialog?
                daitranthanhoa Level 1

                i use Global value, but it show error: For modal dialog or warning is active, you can not process the requested operation

                When call: oDialog.Destroy()

                • 5. Re: How close a Dialog?
                  Loic.Aigon Adobe Community Professional

                  If you are using a modal dialog, I have no idea how you can run a separate script. You might have wanted to mean a secondary function ?

                   

                  in this case, you can either choose to call w.close() or btn.notify()

                  var main = function() {
                    var w = new Window('dialog');
                  
                  
                    var closeBtn = w.add('button',undefined,"w.close()");
                  
                    closeBtn.onClick = function() {
                    w.close();
                    };
                  
                  
                    var btn = w.add('button',undefined,"closing w through external func");
                    btn.onClick = function() {
                    pleaseClose(w);
                    }
                  
                    var btn2 = w.add('button',undefined,"closing w through external func & btn.notify()");
                    btn2.onClick = function() {
                    pleaseCloseViaNotify(closeBtn);
                    }
                  
                  
                    w.show();
                  }
                  
                  
                  
                  
                  function pleaseClose(w) {
                    w.close();
                  }
                  
                  
                  function pleaseCloseViaNotify(btn){
                    btn.notify('onClick');
                  }
                  
                  
                  main();
                  

                   

                  But you are probably overcomplicating stuff here. Just keep track of your w object and it should be fine.

                  • 6. Re: How close a Dialog?
                    LSH_246 Level 1

                    Hi,

                     

                    It's not a palette like an InDesign palette. It will look exactly like a dialog, but it won't be modal. Do you actually need the dialog to be modal? If so, then Loic's last suggestion of adding event handlers is a good route to follow.

                     

                    However, if all you want is a non-modal dialog, pass "palette" to the Window constructor, and you'll get a non-modal dialog.

                     

                    Lawrence

                    • 7. Re: How close a Dialog?
                      daitranthanhoa Level 1

                      Current i using COM adobe in VB.net

                      I using a Thread, to show dialog,

                      So i still can process some functions when dialog opening.

                      So After process, i want close this dialog.