Dynamically adding Icon Buttons

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Tom, Kukurykus

norbert_ds

Dynamically adding Icon Buttons

Post by norbert_ds »

Hi,

What I am trying to achieve is a display a list of folders in a window. Each of these folders contain PNG files.

I want to display these png files as icons in a panel in the window. While it displays the first file in the loop it does not display the rest. Any ideas on what I am doing wrong in the following code snippet?

w.DropDownList.onChange= function()
{
iconFolder=Folder("/C/XYZ/"+this.selection.text);
iconFileList= iconFolder.getFiles("*.png");
x=10;
y=10;
for (var h=0; h<iconFileList.length; h++) { w.iconPnl.add ("iconbutton", [x,y,70,70], iconFileList[h]); x=x+71; }

}
Patrick

Dynamically adding Icon Buttons

Post by Patrick »

Not sure what is wrong in your example. I just tried it from scratch doing a while loop and this worked for me:

Code: Select all// folder
iconFileList= Folder("/C/").getFiles("*.txt");

// loop through file list
x = 0;
while (x < iconFileList.length)
{
   // add your button here
   alert(iconFileList[x].name);
   x++;
}

Patrick
norbert_ds

Dynamically adding Icon Buttons

Post by norbert_ds »

Thanks for your respose Patrick,

I've redone my code a bit.

Could you tell me whats wrong in the following code?

Thanks in advance!

Regards
Norbert D'Souza

Code: Select all   for (var h=0; h<iconFileList.length; h++)
   {
      this["upBtn"+h]=this.selection.panel.add ("iconbutton", [x1,y1,x2,y2], iconFileList[h])
      row=row+1
      x1=x1+62;
      x2=x2+62;
      if (row==4)
      {
         row=0
         x1=10
         y1=y1+62;
         x2=70
         y2=y2+62;
      }
   }


   
}

"upBtn"+h.onClick=function(h){
   alert("Here")
   }