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

how to use listitem control and listbox control with js in indesign?

Community Beginner ,
Mar 11, 2008 Mar 11, 2008
Anyone can give me some examples?
TOPICS
Scripting
807
Translate
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
Guest
Mar 11, 2008 Mar 11, 2008
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
Translate
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 ,
Mar 11, 2008 Mar 11, 2008
>Note this code as not been tested at all.

Works great!

Peter
Translate
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
Guest
Mar 11, 2008 Mar 11, 2008
Wow!

Bob
Translate
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 Beginner ,
Mar 11, 2008 Mar 11, 2008
LATEST
Thanks Bob,it works great!
Translate
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