1 Reply Latest reply on May 5, 2010 4:57 PM by herr mueller

    Help! Scriptui close method blocks interraction:

    herr mueller Level 1

      I am not new to Scripting Indesign but have opted to use the normal dialog options till now and am a little confused by several of the scriptui methods.

       

      I first attempted to search this forum but the few examples I found were rather vague so I appeal to you now.

       

      It seems that when I call the close() method on a scriptui dialogs ok or cancel event, it merely hides the object.

       

      The hidden object (dialog) prevents execution of any script; (ie: app.documents.add();)

       

      and returns the following error:

       

           Error: Cannot handle the request because a modal dialog or alert is active.

       

      Can anyone provide a clear and precise example of closing a script ui dialog then creating a simple document without interference?

       

      This may benefit others besides me who are finally making the move into the scriptui universe.

       

      Oh to have CS5 and Flex throughout my company instead of CS4 and scriptui !

        • 1. Re: Help! Scriptui close method blocks interraction:
          herr mueller Level 1

          I was able to find a good example for this question from an old script by Dave Saunders:

           

          http://jsid.blogspot.com/2007/08/scriptui-dialog-with-interacting.html

           

          //DESCRIPTION: Sample Dialog

          myDlg = new Window('dialog', 'Example');
          myDlg.orientation = 'row';

          // Add action buttons
          myDlg.btn1 = myDlg.add('button', undefined, 'Disable Him');
          myDlg.btn2 = myDlg.add('button', undefined, 'Disable Him');
          myDlg.closeBtn = myDlg.add('button', undefined, 'Close');

          // Add button functions
          myDlg.btn1.onClick = function() {
            if (this.text == 'Disable Him') {
              this.text = 'Enable Him';
              myDlg.btn2.enabled = false;
            } else {
              this.text = 'Disable Him';
              myDlg.btn2.enabled = true;
            }
          }

          myDlg.btn2.onClick = function() {
            if (this.text == 'Disable Him') {
              this.text = 'Enable Him';
              myDlg.btn1.enabled = false;
            } else {
              this.text = 'Disable Him';
              myDlg.btn1.enabled = true;
            }
          }

          myDlg.closeBtn.onClick = function() {
            this.parent.close(1);
          }

          result = myDlg.show();
          if (result == 1) {
            alert("You used the Close button");
            app.documents.add();
          }