Thread View: adobe.scripting.indesign
3 messages
3 total messages
Started by Eric
Mon, 22 Dec 2008 23:07
[CS3, JS] Stuck on DropDownList again
Author: Eric
Date: Mon, 22 Dec 2008 23:07
Date: Mon, 22 Dec 2008 23:07
32 lines
1553 bytes
1553 bytes
Hi all. Trying to build a simple dialog in JS via resource and having a heck of a time!
Anyone able to tell me why my drop down list is always blank in the following resource?
res =
"dialog { \
orientation: 'column', \
alignChildren: 'right', \
range: Group { \
orientation: 'row', \
s: StaticText { text:'Range:' }, \
e: EditText { preferredSize: [200, 20] } \
}, \
master: Group { \
orientation: 'row', \
s: StaticText { text: 'Apply Master:' }, \
l: DropDownList { \
stringList:['A-Master', 'B-Master'], \
preferredSize: [200, 20] }, \
}, \
buttons: Group { \
orientation: 'row', \
alignment: 'right', \
okBtn: Button { \
text:'OK', properties:{ name:'ok' } \
}, \
cancelBtn: Button { \
text:'Cancel', properties:{ name:'cancel' } \
} \
} \
}";
Sorry if this a really bone-headed question. I always have a heck of a time with the Dialog class it seems. :-/
Re: [CS3, JS] Stuck on DropDownList again
Author: Peter Kahrel
Date: Tue, 23 Dec 2008 09:44
Date: Tue, 23 Dec 2008 09:44
55 lines
1906 bytes
1906 bytes
Eric,
stringList is a property in the 'classic' dialog model, not in scriptUI. There's a creation problem with dropdowns in scriptUI in that the property name to use is "items", which throws an error:
l: DropDownList { \
items: ['A-Master', 'B-Master'], \
preferredSize: [200, 20] }, \
So you'd have to use something like this:
l: DropDownList { \
{properties: {items: ['A-Master', 'B-Master']}, \
preferredSize: [200, 20] }, \
To show some item after the window has been created, do this:
w = new Window (res);
w.master.l.selection = 1;
w.show()
This is one of the reasons why I think that resource strings are a pain. The reason cited most often for using resource strings is that they allow you to separate design features from code. But this separation is also possible without using resoource strings. And ironically, you used code in your res. string. I'd think that the purist would do something like this:
...
...
l: DropDownList {preferredSize: [200, 20]}, \
...
...
w = new Window (res);
w.master.l.add ('item', 'A-Master');
w.master.l.add ('item', 'B-Master');
w.master.l.selection = 1;
w.show()
After all, the contents of the array is not part of the design.
Peter
Re: [CS3, JS] Stuck on DropDownList again
Author: Eric
Date: Tue, 23 Dec 2008 17:12
Date: Tue, 23 Dec 2008 17:12
19 lines
1314 bytes
1314 bytes
Hi Peter,
Thanks for your help!
Yes, I actually started out initially in "purist mode". Apparently, I fell off the tracks due to wanting to add all the items at once via something like:
w.master.l.stringList = masterSpreads.everyItem().name
As near as I can tell (now), that's just not possible. When I use "items" rather than "stringList", I get back a read-only error. Which is a step up from a broken dialog box at least, but still--argh.
This loop works at least, though, so I am back on track.
for( i=0; i < masterSpreads.count(); ++i ) {
win.master.l.add( 'item', masterSpreads[i].name );
}
Thanks again for taking the time to write all that all up. Very useful info!
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads