Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

ScriptUI: How to update Listbox values? (CC2014)

$
0
0

Is there way to update listbox element that filled with JS array elements. If I push more elements to the array, how I can re-render it in ScriptUI? Is there way to do this.

 

I know there is way just to add elements to listbox like in Peter Kahrel's PDF. But this isn't so dynamic:

 

var w = new Window ("dialog");
var myList = w.add ("listbox", undefined, ["one", "two", "three"]);
var b = w.add ("button", undefined, "Add");
b.onClick = function () {myList.add ("item", "zero", 0)}
w.show ();

 

How about if I wan't to update listbox when I have changed my arrays, like below:

 

// Create example array
var testArr = ['item1', 'item2']
$.writeln(testArr.length);

startGUI();
function startGUI() {
       // Window    var win = new Window( "palette", script_name, undefined, { resizeable:true } );    win.orientation = "column";    win.alignChildren = ["fill", "fill"];       // Listbox    var myListbox = win.add ("listbox", undefined, testArr,         {         numberOfColumns: 1,         showHeaders: true,         columnTitles: ['Name']    });    // Add Item To Array    var addItem = win.add("button", undefined, "Add Item");    addItem.onClick = function() {          testArr.push ('item3');        $.writeln(testArr.length);    }     // Quit BTN    win.quitBtn = win.add("button", undefined, "Close");    win.quitBtn.onClick = function() {          win.close();      }    win.show();
}

 

Maybe there is some update funtion on ScriptUI. I tried to search solution without success. Any help?


Viewing all articles
Browse latest Browse all 12845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>