Copy link to clipboard
Copied
Hello everyone once again! I'm working a dialog window containing a listbox that loads an external list.txt with icones.png, but today I've been getting an error message:
myList.items .image = File ("~ / Desktop / Icons /" + imgs );
Guys can anyone test my script and check for the cause of the error.
My version of Photoshop:
Adobe Photoshop Version: 20.0.0 20180920.r.24 2018/09/20: 1193433 x64
var aFile = File ( "~/Desktop/ListIcons.txt" );
aFile.open('r'); var stringFromTextFile = aFile.read(); var imgs = stringFromTextFile.split("\n");
var w = new Window("dialog");
var myList = w.add("listbox");
for (var i = 0; i < imgs.length; i++) {
myList.add("item");
myList.items.image = File("~/Desktop/Icons/"+ imgs);
}
myList.preferredSize = [120,190];
w.show();
Here lists and icons:
listbox teste https://www.mediafire.com/file/zo6yjfmh8cprz9z/listbox_teste.rar/file
var aFile = File ( "~/Desktop/ListIcons.txt" );
aFile.open('r'); var stringFromTextFile = aFile.read(); var imgs = stringFromTextFile.split("\n");
var w = new Window("dialog");
var myList = w.add("listbox");
for (var i = 0; i < imgs.length; i++) {
myList.add("item");
if (imgs!="") myList.items.image = File("~/Desktop/Icons/"+ imgs);
}
myList.preferredSize = [120,190];
w.show();
Copy link to clipboard
Copied
var aFile = File ( "~/Desktop/ListIcons.txt" );
aFile.open('r'); var stringFromTextFile = aFile.read(); var imgs = stringFromTextFile.split("\n");
var w = new Window("dialog");
var myList = w.add("listbox");
for (var i = 0; i < imgs.length; i++) {
myList.add("item");
if (imgs!="") myList.items.image = File("~/Desktop/Icons/"+ imgs);
}
myList.preferredSize = [120,190];
w.show();
Copy link to clipboard
Copied
Perfect, great grade for youJJMack It helped me a lot.
Copy link to clipboard
Copied
How to put an event on.click at each icon?
Copy link to clipboard
Copied
Its a list I would think you would not have an on click event for each list you woul gets an index number see which Icon was click on. The you would perhaps change the dialog to show that icon selected and show the dialog. you could something different for each icon click on. I don't know scriptUI have only other users code that used pull-down list. These has a index value for the item being displayed in the pull down text list. I do not know actually how an image list works. Yours looks like the field is larger then a single icon more a scrollable list.
Copy link to clipboard
Copied
If it doesn't have an on.click event, what's the point of making a listbox with icons?
Copy link to clipboard
Copied
I don't know if that answers your question geppettol66959005 , JJMack
I intend to use the function of each icon like this here:
///////////////////////////////
//Event on each icon: In my case
myList.onChange = function(){
if(parseInt(myList.selection) == 0){alert("Item 1")}
if(parseInt(myList.selection) == 1){alert("Item 2")}
if(parseInt(myList.selection) == 2){alert("Item 3")}
myList.selection = null
}
Copy link to clipboard
Copied
I don't understand why in Photoshop it looks unpleasant in the UI when the item is selected.
If we compare with other Adobe products, this looks more like a glitch. Have they noticed it yet?
I recommend deselecting the selection:
myList.selection = null
Copy link to clipboard
Copied
In every new version of photoshop there are new bugs
and worsen the development of ui script windows
in my opinion adobe no longer has an interest in ui script windows because it focuses on windows html extensions