Copy link to clipboard
Copied
Is what I'm trying to do below possible? I want to loop through an array and create radio buttons and at least set whether they're enabled. I know my syntax is way off here, but just wondering if I can create radio1, radio2 and radio3 using variables or if I have to hardcode these. Plase note "radios.radio.eval(i).enabled" is a complete shot in the dark, and I've confirmed it doesn't work, but a lot of Adobe scripting is just closing your eyes and guessing.
radios = win.add ("group");
radios.radio1 = radios.add ("radiobutton", undefined, "Long");
radios.radio2 = radios.add ("radiobutton", undefined, "Short");
radios.radio3 = radios.add ("radiobutton", undefined, "Full");
for(i = 1; i<=3; i++) {
radios.radio.eval(i).enabled = false;}
you could try adding the radio button along with the state in your loop
var w = new Window ('dialog', 'Create Radio Buttons');
var g = w.add('group');
var radioNames = ['tomatoes', 'onions', 'potatoes'];
var radioState = [false, true, false];
var r = [];
for (var i=0; i<radioNames.length; i++) {
r = g.add('radiobutton', undefined, radioNames);
r.value = radioState;
}
w.show();
Copy link to clipboard
Copied
you could try adding the radio button along with the state in your loop
var w = new Window ('dialog', 'Create Radio Buttons');
var g = w.add('group');
var radioNames = ['tomatoes', 'onions', 'potatoes'];
var radioState = [false, true, false];
var r = [];
for (var i=0; i<radioNames.length; i++) {
r = g.add('radiobutton', undefined, radioNames);
r.value = radioState;
}
w.show();
Copy link to clipboard
Copied
Thanks Carlos! I had a bit of trouble at first with scope, as I was using an example that had radios with functions, but I was able to make them global and your instructions worked like a charm. I clearly need a better understanding of the object model since I ask so many novice questions, but appreciate the community always coming through answering and documenting hidden features.