4 Replies Latest reply on Nov 9, 2017 6:11 AM by smithcgl9043167

    Curious about Dialog Box Alignment! when opening

    smithcgl9043167 Level 2

      Hello guys!

      1- Is there any command I can open, a native Photoshop dialog box from a custom dialog box with the same "x, y" coordinates?

      2- How do I abort this error on line 14 when I click the cancel button?

      Thank you

       

      win=new Window("dialog","Window test!",[0,0,355,125]);
      panel=win.add("panel",[10,10,340,110],"Open a dialog box in the same location x, y of this window!");
      btn_open=panel.add("button",[33,34,283,54],"Open a window .. Ex: Levels");
      
      ////////////////
      btn_open.onClick = function() {
      if(app.documents.length == 0){
          alert("There needs to be an open document!");
          }
      
      else {
          docRef = app.activeDocument;
          var descriptor = new ActionDescriptor();
      executeAction( stringIDToTypeID( "levels" ), descriptor, DialogModes.ALL);
         }
      }
      
      win.center();
      win.show();
      
        • 1. Re: Curious about Dialog Box Alignment! when opening
          Davide_Barranca Adobe Community Professional

          Do you mean the Levels dialog position? I don't think it's possible, or at least I'm not aware of native dialog positioning.

          You can try/catch the Levels canceling as follows (I've slightly simplified your code)

           

          win=new Window("dialog","Window test!",[0,0,355,125]);  
          panel=win.add("panel",[10,10,340,110],"Open a dialog box in the same location x, y of this window!");  
          btn_open=panel.add("button",[33,34,283,54],"Open a window .. Ex: Levels");  
            
          ////////////////  
          btn_open.onClick = function() {  
              if(app.documents.length == 0){  
                  alert("There needs to be an open document!");
                  // you can also win.close();
                  return;
              }
              try {
                  var descriptor = new ActionDescriptor();  
                  executeAction( stringIDToTypeID( "levels" ), descriptor, DialogModes.ALL);  
              } catch(e) {
                  // do whatever you need, or
                  win.close()
              }
          }  
            
          win.center();  
          win.show();
          

           

          Hope this helps,

           

          Davide

          1 person found this helpful
          • 2. Re: Curious about Dialog Box Alignment! when opening
            smithcgl9043167 Level 2

            Hi Davide ... What a pity that maybe there is no way to do this, but I already serve as a consolation to your answer regarding my question number 2, this will help me a lot. Thank you.

             

            DBarranca " I don't think it's possible, or at least I'm not aware of native dialog positioning."

              Would it be possible to position the dialog in another personalized dialog ?.

            • 3. Re: Curious about Dialog Box Alignment! when opening
              Pedro Cortez Marques Level 3

              Hi you can try to use frameLocation like this and regarding the location of the second native window, I can't set frameLocation for it.

              However, its location will always be the last used one!

              So, you just confirm it once (drag it to where you want it to be) and its position and the next runs will be the same location x,y. This works at least on CC(2017) and on windows.

               

              win=new Window("dialog","Window test!",[0,0,355,125]);
              panel=win.add("panel",[10,10,340,110],"Open a dialog box in the same location x, y of this window!");
              btn_open=panel.add("button",[33,34,283,54],"Open a window .. Ex: Levels");
              
              ////////////////
              btn_open.onClick = function() {
                  if(app.documents.length == 0) {
                      alert("There needs to be an open document!");
                      // you can also win.close();
                      return;
                  }
                  try {
                      $.level=0;
                      var descriptor = new ActionDescriptor();
                      executeAction( stringIDToTypeID( "levels" ), descriptor, DialogModes.ALL);
                      $.level=1;
                  } catch(e) {  
                      // do whatever you need, or  
                      win.close();
                  }  
              }    
              
              winX=20;
              winY=20;
              win.frameLocation=[winX,winY];
              
              win.show();
              
              1 person found this helpful
              • 4. Re: Curious about Dialog Box Alignment! when opening
                smithcgl9043167 Level 2

                Hi Pedro Cortez Marquesthanks for replying! I have tested your suggestion here! ..... But this feature already comes by default, by the same with the native windows. I really thought there was no appeal for that.