Sg2.9
Radio Button Groups
Recent RSS
Radio Button Groups
From:  Chris Deutsch
Date:  21. February 2010, 21:15

I have several radio buttons in my dialog, supposedly belonging to different groups. But when one is selected, ALL others are deselected.

Is there a way to define radio button groups that don't interfere with each other?

Chris

Re: Radio Button Groups
Date:  22. February 2010, 14:06

Hi Chris, that's strange! Could you post some sample code that demonstrates this behaviour?

Re: Radio Button Groups
From:  Chris Deutsch
Date:  23. February 2010, 14:23

Honestly, I don't even see how Illustrator could know that the buttons are meant to belong to different groups. Let's say I define 2 radio buttons in the script like so:

var radio1 = new RadioButton(dialog){
text: "Radio 1",
checked: true,
onClick: function(){
radio2.checked = false;
}
}

var radio2 = new RadioButton(dialog){
text: "Radio 2",
checked: false,
onClick: function(){
radio1.checked = false;
}
}

And later on, in a different place in the script, I define 2 different radio buttons:

var selection1 = new RadioButton(dialog){
text: "Selection 1",
checked: true,
onClick: function(){
selection2.checked = false;
}
}

var selection2 = new RadioButton(dialog){
text: "Selection 2",
checked: false,
onClick: function(){
selection1.checked = false;
}
}

I'm not quite sure why I specified the onClick behaviour in the first place... seems to work just fine without it.

I didn't find any means of specifying groups for the radio buttons in the reference.

Thanks!

Chris

Re: Radio Button Groups
From:  Jürg Lehni
Date:  23. February 2010, 16:46

Try creating another control in between the two groups, or try grouping them within a Frame.

To see how to use these things maybe have a look at the Core/JavaScript/gui code, e.g. main.js

Apparently ADM should handle the groups automatically, but only if they are numbered consecutively and separated as groups.

Unfortunately the UI / ADM stuff is on its way out as Adobe has chosen to deprecate in CS5 and remove it entirely in CS6, in order to finally switch to Cocoa / 64 bit. Therefore we start looking for alternative and will not spend a lot of time fixing bugs in existing UI code.

Re: Radio Button Groups
From:  Jürg Lehni
Date:  23. February 2010, 16:54

...But as a solution for the time in-between I am working on a Dialog.createPalette method that receives the same parameters as Dialog.prompt but creates a floating palette for scripts that is not modal. This should fulfil the needs for most scripts anyway. In Dialog.prompt, an alternative to radio buttons is a popup menu list where only one item can be chosen. Maybe you'd want to wait for this feature?

Re: Radio Button Groups
From:  Chris Deutsch
Date:  23. February 2010, 17:02

It's not a big deal, since I've just replaced the radio buttons with checkboxes and gave them onClick behaviour similar to that of radio buttons. But thanks!

Scripts
08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
Posts
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19
Script of the Moment
Gearwheels 18.08.08