Skip to main content
frameexpert
Community Expert
Community Expert
September 6, 2018
Answered

Refreshing listbox values

  • September 6, 2018
  • 1 reply
  • 1080 views

Hi, I am using ExtendScript on Windows 7. I have a listbox with data in it. I want to be able to update the listbox with a brand new array of data on the fly when the user clicks the << or >> buttons. Here is what my palette looks like:

In my button events, I have:

palette.attrValues.items = values;

where values is the new array of strings. But the palette does not update. Any advice would be appreciated. Thank you very much.

This topic has been closed for replies.
Correct answer frameexpert

Thanks to Peter Kahrel excellent ScriptUI guide, I found out a good way to do it. I simply create a new list box, add it to the palette and delete the old one. It works great. I am using this function inside my script. It may not make total sense because you can't see the whole script, but you should be able to see where I am making a new list and deleting the old one.

function updateList () {

    var newList;

    palette.currIndex = set.index;

    palette.text = "attribute: " + set.name;

    // Create a new list for the new values.

    // Use the existing list's bounds so the new list will be the same size/location.

    // set.values contains the new values for the listbox.

    newList = palette.listGroup.add ("listbox", palette.attrValues.bounds, set.values, {multiselect:true});

    newList.alignment = ['fill', 'fill'];

    // Delete the old list.

    palette.listGroup.remove (palette.attrValues);

    // Update the variable so it points to the new list.

    palette.attrValues = newList;

}

1 reply

frameexpert
Community Expert
frameexpertCommunity ExpertAuthorCorrect answer
Community Expert
September 7, 2018

Thanks to Peter Kahrel excellent ScriptUI guide, I found out a good way to do it. I simply create a new list box, add it to the palette and delete the old one. It works great. I am using this function inside my script. It may not make total sense because you can't see the whole script, but you should be able to see where I am making a new list and deleting the old one.

function updateList () {

    var newList;

    palette.currIndex = set.index;

    palette.text = "attribute: " + set.name;

    // Create a new list for the new values.

    // Use the existing list's bounds so the new list will be the same size/location.

    // set.values contains the new values for the listbox.

    newList = palette.listGroup.add ("listbox", palette.attrValues.bounds, set.values, {multiselect:true});

    newList.alignment = ['fill', 'fill'];

    // Delete the old list.

    palette.listGroup.remove (palette.attrValues);

    // Update the variable so it points to the new list.

    palette.attrValues = newList;

}