Copy link to clipboard
Copied
Hi!
I have a dialog with a group of 4 radio buttons, & each radio button option has a textBox or dropdown, see screenshot:
How do I enable only the dropdown or textBox of the selected radioButton?!
Thanks a lot in advance!!!
Here is a possible approach:
...var w = new Window('dialog'),
g = w.add('group')
g1 = g.add('group'),
g2 = g.add('group'),
btn = w.add('button', undefined, "Cancel"),
cb, dd;
for ( i = 0; i < 5; i++ ) {
cb = g1.add('checkbox',undefined,(i+1));
cb.index = i;
cb.alignment = "fill";
dd = g2.add('dropdownlist',undefined,(i+1));
dd.enabled = false;
dd.alignment = "fill";
}
g1.addEventListener ('mousedown', function(evt){
var cb = evt.target, index, n = g1.children.length, cb, dd, value;
if(cb.constructor.name != "Che
Copy link to clipboard
Copied
Here is a possible approach:
var w = new Window('dialog'),
g = w.add('group')
g1 = g.add('group'),
g2 = g.add('group'),
btn = w.add('button', undefined, "Cancel"),
cb, dd;
for ( i = 0; i < 5; i++ ) {
cb = g1.add('checkbox',undefined,(i+1));
cb.index = i;
cb.alignment = "fill";
dd = g2.add('dropdownlist',undefined,(i+1));
dd.enabled = false;
dd.alignment = "fill";
}
g1.addEventListener ('mousedown', function(evt){
var cb = evt.target, index, n = g1.children.length, cb, dd, value;
if(cb.constructor.name != "Checkbox") return;
index = cb.index;
value = !cb.value;
while ( n-- ) {
dd = g2.children
; cb = g1.children
; dd.enabled = !value? false : ( n == index );
value && n != index && cb.value = false;
}
});
g1.children[0].value = true;
g2.children[0].enabled = true;
g1.orientation = g2.orientation = "column";
g.orientation = "row";
w.show();
Although I would process differently myself using constructors and somme event programming:
Event-Driven Programming with ExtendScript | Ozalto
HTH
Copy link to clipboard
Copied
Is this JavaScript?!
It doesn't look familiar...
Copy link to clipboard
Copied
I think that what confuses you is that you may have used the InDesign own Dialog Class for building your UI while I am offering an UI based on ScriptUI (see ScriptUI for Dummies for more details).
But yes, it's Javascript, well ExtendScript.
Copy link to clipboard
Copied
You're right!!!
Thank you for telling me about this scriptUI, it is very handy, especially for creating floating Panels!!!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more