Hi I have a small script here which someone from these forums posted not too long ago... was it Noel? Either way, this script is fantastic and brings up a sub-menu to switch documents. When the menu pops up, it shows a list of all open documents in Photoshop. (I actually modified this script so all it does is switch documents instead of copying the active layer to another document.. somehow I managed it with the very basic knowledge I have )
The default document selection (the document name that is highlighted in the menu) when the list opens is "0"
I'm looking for a way to get the highlighted selection to reflect the active document instead of "0".
I think it's somewhere in this line of code:
win.NewList.selection = 0;
and I've tried changing the 0 to "actLay" and also "activeLayer" but it throws me an error message. Is there a way to get the active document as the highlighted selection? Here's the code...
var aDoc = app.activeDocument;
var AllDocs = app.documents;
var actLay = aDoc.activeLayer;
if (AllDocs.length > 1) {
var itemDoc = null;
var win = new Window("dialog","Switch Documents");
this.windowRef = win;
win.Txt1 = win.add ("statictext", undefined, "Switch to which document?");
win.NewList=win.add ("dropdownlist", undefined)
for (var m = 0; m < AllDocs.length; m++) {
win.NewList.add("item", AllDocs[m].name)
}
win.NewList.selection = 0;
itemDoc = win.NewList.selection.actLay;
win.cancelBtn = win.add("button", undefined, "Switch");
win.cancelElement = win.cancelBtn;
win.NewList.onChange= function () {
itemDoc = win.NewList.selection.index; return itemDoc; }
win.show();
app.activeDocument = app.documents[itemDoc];
app.refresh();
}