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

Error loading external items in listbox

Engaged ,
Aug 16, 2019 Aug 16, 2019

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

TOPICS
Actions and scripting

Views

1.7K

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 , Aug 16, 2019 Aug 16, 2019

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

Votes

Translate

Translate
Adobe
Community Expert ,
Aug 16, 2019 Aug 16, 2019

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

JJMack

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
Engaged ,
Aug 16, 2019 Aug 16, 2019

Copy link to clipboard

Copied

Perfect, great grade for youJJMack It helped me a lot.

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
Advocate ,
Aug 17, 2019 Aug 17, 2019

Copy link to clipboard

Copied

How to put an event on.click at each icon?

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
Community Expert ,
Aug 17, 2019 Aug 17, 2019

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.

JJMack

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
Advocate ,
Aug 17, 2019 Aug 17, 2019

Copy link to clipboard

Copied

If it doesn't have an on.click event, what's the point of making a listbox with icons?

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
Engaged ,
Aug 17, 2019 Aug 17, 2019

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

}

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
Engaged ,
Aug 17, 2019 Aug 17, 2019

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?

Capturar.JPG

I recommend deselecting the selection:

myList.selection = null

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
Advocate ,
Aug 18, 2019 Aug 18, 2019

Copy link to clipboard

Copied

LATEST

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

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