Copy link to clipboard
Copied
Hey,
Basicly i have a list of all the files that are open in photoshop.
I was wondering if I could push a variable called "New file" into this list.
And check afterwards if the file is called like this.
var itemDoc = null;
//Dropdown list
w.NewList=w.add ("dropdownlist", undefined, app.documents);
w.NewList.preferredSize.width = 275;
//Place open files in list
w.NewList.selection = 0;
itemDoc = w.NewList.selection.index;
//Get selected document from list
w.NewList.onChange= function ()
{
itemDoc = w.NewList.selection.index;
return itemDoc;
}
Something like this?
#target photoshop
var fileList = new Array()
getList ();
var dlg = new Window('dialog','List of open files')
var dropList = dlg.add('dropdownlist',undefined,fileList);
dropList.selection = 0;
dropList.onChange = function(){
//some code here
}
dlg.show();
function getList(){
fileList = new Array();
for(var i=0;i<app.documents.length;i++){
fileList.push(app.documents.name)
}
fileList.push('New File')
}
Copy link to clipboard
Copied
Something like this?
#target photoshop
var fileList = new Array()
getList ();
var dlg = new Window('dialog','List of open files')
var dropList = dlg.add('dropdownlist',undefined,fileList);
dropList.selection = 0;
dropList.onChange = function(){
//some code here
}
dlg.show();
function getList(){
fileList = new Array();
for(var i=0;i<app.documents.length;i++){
fileList.push(app.documents.name)
}
fileList.push('New File')
}
Copy link to clipboard
Copied
var w = new Window("dialog");
var itemDoc = null;
var docs = app.documents;
var arr = [];
var n = docs.length;
while ( n--) arr
= docs .name; arr.push ( "New file" );
//Dropdown list
w.NewList=w.add ("dropdownlist", undefined, arr);
w.NewList.preferredSize.width = 275;
//Place open files in list
w.NewList.selection = 0;
itemDoc = w.NewList.selection.index;
var btn = w.add('button',undefined,"go");
//Get selected document from list
w.NewList.onChange= function ()
{
itemDoc = w.NewList.selection.index;
return itemDoc;
}
btn.onClick = function() {
alert("You want to open"+(w.NewList.selection.index == w.NewList.children.length-1? " a new file" : "an existing file") );
}
w.show();