2 Replies Latest reply on Jul 24, 2008 11:32 PM by (SophieG)

    creating a dialog from another dialog

      I need to modify a layer with informations set by the user in a dialog I wrote.
      Everything works fine when I run the script "manually" (comment test 2).

      Then I tried to launch the script from a onclick event defined on a button in an other dialog. The first action I do is to close the first dialog before opening the second.(comment test 1).

      But in this case I obtain the message telling that executing the request is impossible because a modal dialog or an alert is active.

      Any idea ?

      thanks,

      Sophie

      /**** test 1 ****/
      openDlg2();
      /****/

      /**** test 2 ****/
      var dlg1 = new Window("dialog", "Dialog 1");
      dlg1.btn = dlg1.add("button", undefined, "open dlg2");
      dlg1.btn.onClick = function()
      {
      dlg1.close();
      openDlg2();
      };
      dlg1.show();
      /****/

      function openDlg2()
      {
      var dlg2 = new Window("dialog", "Dialog 2");
      dlg2.OKBtn = dlg2.add("button", undefined, "Create layer", {name:"ok"});
      var v = dlg2.show();
      if (v == 1)
      {
      var newLayer = app.activeDocument.layers.add();
      }
      }
        • 1. Re: creating a dialog from another dialog
          Harbs. Level 6
          In Script UI, the dialogs are going to be nested no matter what you do.
          (At least that's what I've found...)

          If you move that layer.add() out of your function to only be executed
          after BOTH dialogs have been closed, you should be okay.

          Harbs
          • 2. Re: creating a dialog from another dialog
            Level 1
            Thanks, it works :

            var retDlg2;
            var dlg1 = new Window("dialog", "Dialog 1");
            dlg1.btn = dlg1.add("button", undefined, "open dlg2");
            dlg1.btn.onClick = function()
            {
            dlg1.close();
            openDlg2();
            };
            dlg1.show();
            if (retDlg2 == 1)
            {
            var newLayer = app.activeDocument.layers.add();
            }

            function openDlg2()
            {
            var dlg2 = new Window("dialog", "Dialog 2");
            dlg2.OKBtn = dlg2.add("button", undefined, "Create layer", {name:"ok"});
            retDlg2 = dlg2.show();
            }