Copy link to clipboard
Copied
Hello,
Is it possible to add a event listener for radiobuttonGroups1 and radiobuttonGroups3 where those two options can’t be selected at the same time?
So if you click a button in radiobuttonGroups1, all buttons in radiobuttonGroups3 are deselected and the other way around so only one of those two groups can be active at a time.
I found an example in Peter Kahrel’s ScriptUI for dummies but only for “new Window ("dialog”);” dialog type………nothing for the “app.dialogs.add type”
Any help would be greatly appreciated!
Below is the dialog code.
var myDialog = app.dialogs.add({name:"Color Swatch Options", canCancel:true});
with (myDialog){
with (dialogColumns.add()){
with (borderPanels.add()){
var myradiogroup3 = radiobuttonGroups.add();
with (myradiogroup3){
var myyesradiobutton3 = radiobuttonControls.add({staticLabel:'Check For Spot Color Usage "No"', checkedState:false});
var mynoradiobutton3 = radiobuttonControls.add({staticLabel:'Check For Spot Color Usage "Yes"'});
staticTexts.add({staticLabel:"", minWidth:15});
}
}
with (borderPanels.add()){
var myradiogroup2 = radiobuttonGroups.add();
with (myradiogroup2){
var myyesradiobutton2 = radiobuttonControls.add({staticLabel:'Delete All Unused Swatches "No"', checkedState: false});
var mynoradiobutton2 = radiobuttonControls.add({staticLabel:'Delete All Unused Swatches "Yes"'});
staticTexts.add({staticLabel:"", minWidth:17});
}
}
with (borderPanels.add()){
var myradiogroup1 = radiobuttonGroups.add();
with (myradiogroup1){
var myyesradiobutton1 = radiobuttonControls.add({staticLabel:'Convert Spot Colors To Process "No"', checkedState: false});
var mynoradiobutton1 = radiobuttonControls.add({staticLabel:'Convert Spot Colors To Process "Yes"'});
}
}
}
}
if (myDialog.show() == true){
var Spots2Process = myradiogroup1.selectedButton;
var DeleteUnusedSwatches = myradiogroup2.selectedButton;
var CheckForSpot = myradiogroup3.selectedButton;
myDialog.destroy();
}
Thanks is advance!!
M
Copy link to clipboard
Copied
For those kind of interactions, you may prefer using ScriptUI and Event Driven Programming.
This is how I typically approach this :
See EventManager Library here :
Programmation événementielle en ExtendScript | Ozalto
#include "EventManager.jsinc"
var EM = new EventManager();
var rbPanelFactory = function( parent, label ){
var u,
p = parent.add ( "panel", u, label),
rb1 = p.add('radiobutton',u, "NO" ),
rb2 = p.add('radiobutton',u, "YES" ),
that = this;
p.alignment = ["fill","fill"];
p.orientation = 'row';
rb2.value = true;
rb1.onClick = rb2.onClick = function(){
EM.dispatchEvent("com.ozalto.rbChange", {id:that.id, result:rb1.value} );
}
EM.addEventListener ("com.ozalto.uncheckAll", function(data) {
if ( data.id == that.id ) {
rb1.value=rb2.value=false;
}
});
}
var w = new Window ( "dialog","Event driven UI" ),
g1 = w.add('group'),
g2 = w.add('group'),
p1 = new rbPanelFactory ( g1, 'Check For Spot Color Usage' ),
p2 = new rbPanelFactory ( g1, 'Delete All Unused Swatches' ),
p3 = new rbPanelFactory ( g1, 'Convert Spot Colors To Process' );
p1.id = "p1";
p2.id = "p2";
p3.id = "p3";
EM.addEventListener ("com.ozalto.rbChange", function(data) {
if ( data.id=="p1" && data.result ) {
EM.dispatchEvent("com.ozalto.uncheckAll", {id:"p3"} );
};
});
g1.orientation = "column";
w.show();
FWIW
Loic
Find more inspiration, events, and resources on the new Adobe Community
Explore Now