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

Push to newlist

Explorer ,
May 28, 2018 May 28, 2018

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; 

TOPICS
Actions and scripting

Views

486

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

correct answers 1 Correct answer

Community Expert , May 28, 2018 May 28, 2018

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')

}

Votes

Translate

Translate
Adobe
Community Expert ,
May 28, 2018 May 28, 2018

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')

}

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
People's Champ ,
May 28, 2018 May 28, 2018

Copy link to clipboard

Copied

LATEST

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

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