Copy link to clipboard
Copied
Hi,
I have script for dialog with radio buttons, but I need it to be with check boxes instead ( in Illustrator CS6, javascript 😞
var myDoc = app.activeDocument;
dialogSelection ();
function dialogSelection (docSize){
/////////////// DialogBox Definition///////////////////////
var resultBox=false;
var ressource="dialog { \
text: 'Standard Spot Colors', frameLocation:[100,100], \
MyPanelTemplates: Panel { orientation:'column', alignChildren:['left','Top'], \
text: 'Please select Spot Color', \
title: Group { orientation: 'column', \
myColor1: RadioButton { alignment:'left', text: 'Red', value:true}, \
myColor2: RadioButton { alignment:'left', text: 'Green', value:false}, \
myColor3: RadioButton { alignment:'left', text: 'Blue', value:false}, \
} \
}, \
Valid: Panel { orientation:'column', alignChildren:['left','Top'], \
title: Group { \
CancelBtn: Button { text: 'Cancel', properties:{name:'cancel'} }, \
OkBtn: Button { text: 'OK', properties:{name:'ok'} }, \
} \
}, \
}";
///////////////////////////////////////////////////////////
var dlg = new Window(ressource); //build dialog box
dlg.Valid.title.OkBtn.onClick=function(){ //VALID Button test
resultBox=true;
dlg.close();
return resultBox;
};
dlg.show(); // show dialogbox
if (resultBox){ // if press OK button
if (dlg.MyPanelTemplates.title.varRoundedBC.value){
myColor1 = "Red";
addHPIWhite ('spotwhite', 50, 0, 0, 0);
}
if (dlg.MyPanelTemplates.title.varFlower.value){
myColor2 = "Green";
addHPIWhite ('spotwhite', 50, 0, 0, 0);
}
if (dlg.MyPanelTemplates.title.varHeart.value){
myColor3 = "Blue";
addHPIWhite ('spotwhite', 50, 0, 0, 0);
}
}
}
function addHPIWhite(name, c, m, y, k) {
try {
swatch = app.activeDocument.swatches[name]; // if swatch exists....
addSpot (name+='1', c, m, y, k); // ...add 1 to swatch name
}
catch (e) {
var newSpot = app.activeDocument.spots.add();
newSpot.name = name;
var newColor = new CMYKColor();
newColor.cyan = c;
newColor.magenta = m;
newColor.yellow = y;
newColor.black = k;
newSpot.colorType = ColorModel.SPOT;
newSpot.color = newColor;
var newSpotColor = new SpotColor();
newSpotColor.spot = newSpot;
}
}
Thank you for your help.
Yulia
Copy link to clipboard
Copied
Hi, Yuliascript.
Here is a example replaced with check boxes.
dialogSelection ();
function dialogSelection () {
var state = {},
ressource = "dialog {\
text: 'Standard Spot Colors', frameLocation: [100,100],\
MyPanelTemplates: Panel {\
orientation: 'column', alignChildren: ['left','Top'],\
text: 'Please select Spot Color',\
title: Group {\
orientation: 'column',\
red: Checkbox {alignment:'left', text: 'Red', value:true},\
green: Checkbox {alignment:'left', text: 'Green', value:false},\
blue: Checkbox {alignment:'left', text: 'Blue', value:false},\
}\
},\
Valid: Panel {\
orientation: 'column', alignChildren: ['left','Top'],\
title: Group {\
CancelBtn: Button {text: 'Cancel', properties: {name:'cancel'}},\
OkBtn: Button {text: 'OK', properties: {name:'ok'}},\
} \
}, \
}",
dlg = new Window(ressource);
if (dlg.show() === 1) { // OK button returns 1. Cancel button returns 2.
state.red = (dlg.MyPanelTemplates.title.red.value) ? 50 : 0;
state.green = (dlg.MyPanelTemplates.title.green.value) ? 50 : 0;
state.blue = (dlg.MyPanelTemplates.title.blue.value) ? 50 : 0;
// write your function here.
$.writeln('red: ' + state.red + ', green: ' + state.green + ', blue: ' + state.blue);
}
}
Copy link to clipboard
Copied
Check out this WONDERFUL documentation written by Pete Kahrel.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more