Is this what you need?
getDialog = function() {
var w = new Window( "dialog", "Example" );
w.listBox = w.add( "listbox" );
w.listBox.preferredSize = [ 200, 300 ];
var item1 = w.listBox.add( "item", "Item 1" );
var item2 = w.listBox.add( "item", "Item 2" );
item2.selected = true;
w.listBox.onChange = function() {
if ( this.selection != null ) {
// this.selection is a ListItem
}
}
var g = w.add( "group" );
w.okButton = g.add( "button", undefined, "OK" );
w.okButton.onClick = function() {
this.window.close( 1 );
}
w.canButton = g.add( "button", undefined, "Cancel" );
w.canButton.onClick = function() {
this.window.close( 2 );
}
return w;
}
var w = getDialog();
w.center();
if ( w.show() == 1 ) {
var sel = w.listBox.selection; // sel is now a ListItem
if ( sel != null ) {
// do whatever you need with the item
}
}
Note this code as not been tested at all. But you should be able to get the idea.
Regards
Bob