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();
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
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 ?.
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();
Copy link to clipboard
Copied
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.