• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Curious about Dialog Box Alignment! when opening

Engaged ,
Nov 08, 2017 Nov 08, 2017

Copy link to clipboard

Copied

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();

TOPICS
Actions and scripting

Views

529

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Engaged ,
Nov 08, 2017 Nov 08, 2017

Copy link to clipboard

Copied

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

Davide Barranca - PS developer and author
www.ps-scripting.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 08, 2017 Nov 08, 2017

Copy link to clipboard

Copied

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 ?.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 09, 2017 Nov 09, 2017

Copy link to clipboard

Copied

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();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 09, 2017 Nov 09, 2017

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines