After adding a new document to Photoshop via a dialog window the document loses focus. I have already tried bringToFront() and app.refresh().
Notice that the document remains in focus UNTIL the dialog closes (test by removing win.close()).
Output of app.activeDocument is correct, but the document isn't in focus.
Code: Select allwin = new Window('dialog');
win.btnAdd = win.add('button');
win.btnAdd.text = 'Add new document';
win.btnAdd.onClick = function() {
win.close();
app.documents.add('8 in', '10 in', 300, '8x10');
};
win.center();
win.show();
New document loses focus when dialog window is closed
New document loses focus when dialog window is closed
Have you tried creating a variable for the last created document and using
Code: Select allapp.activeDocument = …
after the window has been closed (with some check to make sure a file has been created)?
Code: Select allapp.activeDocument = …
after the window has been closed (with some check to make sure a file has been created)?
New document loses focus when dialog window is closed
Code: Select allalert(app.activeDocument.name) outputs the correct document name and I have tried redefining app.activeDocument with a reference to the new document. The documents is active, just not in focus.
It appears that the Photoshop application gains focus (because the minimize/maximize/close buttons are enabled) while the document loses focus (because the minimize/maximize/close buttons are disabled).
Note: if there is another document already open the new document is added behind the other document.
Update: Using Mac OSX 10.10, Photoshop CC & Photoshop CS6, this may only be a Mac OSX issue
It appears that the Photoshop application gains focus (because the minimize/maximize/close buttons are enabled) while the document loses focus (because the minimize/maximize/close buttons are disabled).
Note: if there is another document already open the new document is added behind the other document.
Update: Using Mac OSX 10.10, Photoshop CC & Photoshop CS6, this may only be a Mac OSX issue
New document loses focus when dialog window is closed
I suppose this is bad form, but it seems to work.
Code: Select allvar theDoc;
win = new Window('dialog');
win.btnAdd = win.add('button');
win.btnAdd.text = 'Add new document';
win.btnAdd.onClick = function() {
win.close();
theDoc = app.documents.add('8 in', '10 in', 300, '8x10');
};
win.center();
var myReturn = win.show();
try {
app.activeDocument = theDoc;
}
catch (e) {};
Code: Select allvar theDoc;
win = new Window('dialog');
win.btnAdd = win.add('button');
win.btnAdd.text = 'Add new document';
win.btnAdd.onClick = function() {
win.close();
theDoc = app.documents.add('8 in', '10 in', 300, '8x10');
};
win.center();
var myReturn = win.show();
try {
app.activeDocument = theDoc;
}
catch (e) {};
New document loses focus when dialog window is closed
Sincerest thanks for attempting to help with this, but that doesn't fix it. The application and document look exactly as shown in the image above.
The application is in focus, yet the document is NOT.
The application is in focus, yet the document is NOT.
New document loses focus when dialog window is closed
Maybe you should try to delay the creation of the new document right *after* the dialog is closed:
Code: Select allvar addDocument = false;
var win = new Window ('dialog');
win.btnAdd = win.add ('button', undefined, 'Add new document');
win.btnAdd.onClick = function () { addDocument = true; win.close (); };
win.center ();
win.show ();
if (addDocument)
{
app.documents.add ('8 in', '10 in', 300, '8x10');
}
HTH...
Code: Select allvar addDocument = false;
var win = new Window ('dialog');
win.btnAdd = win.add ('button', undefined, 'Add new document');
win.btnAdd.onClick = function () { addDocument = true; win.close (); };
win.center ();
win.show ();
if (addDocument)
{
app.documents.add ('8 in', '10 in', 300, '8x10');
}
HTH...
New document loses focus when dialog window is closed
SOLVED. That's it! Such a simple and elegant solution. Thank you!