Copy link to clipboard
Copied
Hi,
I need to create dialog box to allow user to pick from selection of check boxes in Photoshop CS6, javascript.
Thank you.
Yulia
No this example is only one colour at a time.
This will let you use 3.
...#target photoshop
app.bringToFront();
main();
function main(){
if(!documents.length) {
alert("No documents are open!");
return;
}
var win = new Window('dialog','Spot Channel');
win.orientation='column';
win.alignChildren = 'center';
win.pnl1 = win.add('panel',undefined,'Spot Channel', {borderStyle: 'black'} );
win.pnl1.alignChildren = 'left';
win.pnl1.rb1 = win.pnl1.add('checkbox',undefined,'Colour 1');
win.pnl1.rb1.value=true;
wi
Copy link to clipboard
Copied
ScriptUI supports check boxes and radio buttons. Can you elaborate about what you mean pick from a selection of check boxes. A user can select more than one check box where selecting one radio button turns off other radio buttons in a in its group.
Copy link to clipboard
Copied
Yes, I need user to be able to make multiple selections.
Copy link to clipboard
Copied
Is there a problem in your CS6 where check boxes do not work correctly? Post your script...
Copy link to clipboard
Copied
I don't have it yet, I need one. The user will be adding multiple spot channels to the artwork.
Thank you
Yulia
Copy link to clipboard
Copied
Here is what script I have so far:
var myDoc = activeDocument;
function Color1 (){
var theColor = new SolidColor();
theColor.cmyk.cyan = 50;
theColor.cmyk.magenta = 0;
theColor.cmyk.yellow = 0;
theColor.cmyk.black = 0;
var theCh = myDoc.channels.add();
theCh.kind = ChannelType.SPOTCOLOR;
theCh.name = "test";
theCh.opacity = 50;
theCh.color = theColor;
myDoc.activeLayer.invert();
}
I need dialog that offers, let's say, 3 check boxes for spot channel colors (Color1, Color2 and Color3), and based on user's selection I can call the above function to create the color in the active document.
Thank you very much for your help.
Yulia
Copy link to clipboard
Copied
You need radiobuttons not checkboxs I.E.:-
#target photoshop
app.bringToFront();
main();
function main(){
if(!documents.length) {
alert("No documents are open!");
return;
}
var win = new Window('dialog','Spot Channel');
win.orientation='column';
win.alignChildren = 'center';
win.pnl1 = win.add('panel',undefined,'Spot Channel', {borderStyle: 'black'} );
win.pnl1.alignChildren = 'left';
win.pnl1.rb1 = win.pnl1.add('radiobutton',undefined,'Colour 1');
win.pnl1.rb1.value=true;
win.pnl1.rb2 = win.pnl1.add('radiobutton',undefined,'Colour 2');
win.pnl1.rb3 = win.pnl1.add('radiobutton',undefined,'Colour 3');
win.grp1 = win.add('group');
win.select = win.grp1.add('button',undefined,'Ok');
win.can = win.grp1.add('button',undefined,'Cancel');
win.select.preferredSize = win.can.preferredSize=[70,20];
win.select.onClick=function(){
win.close(0);
if(win.pnl1.rb1.value){
//Radio button 1
var theColor = new SolidColor();
theColor.cmyk.cyan = 50;
theColor.cmyk.magenta = 0;
theColor.cmyk.yellow = 0;
theColor.cmyk.black = 0;
var theCh = activeDocument.channels.add();
theCh.kind = ChannelType.SPOTCOLOR;
theCh.name = "test";
theCh.opacity = 50;
theCh.color = theColor;
activeDocument.activeLayer.invert();
}
else if(win.pnl1.rb2.value){
//Radio button 2
var theColor = new SolidColor();
theColor.cmyk.cyan = 50;
theColor.cmyk.magenta = 0;
theColor.cmyk.yellow = 50;
theColor.cmyk.black = 0;
var theCh = activeDocument.channels.add();
theCh.kind = ChannelType.SPOTCOLOR;
theCh.name = "test";
theCh.opacity = 50;
theCh.color = theColor;
activeDocument.activeLayer.invert();
}
else if(win.pnl1.rb3.value){
//Radio button 3
var theColor = new SolidColor();
theColor.cmyk.cyan = 50;
theColor.cmyk.magenta = 50;
theColor.cmyk.yellow = 0;
theColor.cmyk.black = 0;
var theCh = activeDocument.channels.add();
theCh.kind = ChannelType.SPOTCOLOR;
theCh.name = "test";
theCh.opacity = 50;
theCh.color = theColor;
activeDocument.activeLayer.invert();
}
}
win.center();
win.show();
}
Copy link to clipboard
Copied
Thank you, this is great. Will it allow the user to choose more than one color at the time?
Yulia
Copy link to clipboard
Copied
No this example is only one colour at a time.
This will let you use 3.
#target photoshop
app.bringToFront();
main();
function main(){
if(!documents.length) {
alert("No documents are open!");
return;
}
var win = new Window('dialog','Spot Channel');
win.orientation='column';
win.alignChildren = 'center';
win.pnl1 = win.add('panel',undefined,'Spot Channel', {borderStyle: 'black'} );
win.pnl1.alignChildren = 'left';
win.pnl1.rb1 = win.pnl1.add('checkbox',undefined,'Colour 1');
win.pnl1.rb1.value=true;
win.pnl1.rb2 = win.pnl1.add('checkbox',undefined,'Colour 2');
win.pnl1.rb3 = win.pnl1.add('checkbox',undefined,'Colour 3');
win.grp1 = win.add('group');
win.select = win.grp1.add('button',undefined,'Ok');
win.can = win.grp1.add('button',undefined,'Cancel');
win.select.preferredSize = win.can.preferredSize=[70,20];
win.select.onClick=function(){
win.close(0);
if(win.pnl1.rb1.value){
//Checkbox 1
var theColor = new SolidColor();
theColor.cmyk.cyan = 50;
theColor.cmyk.magenta = 0;
theColor.cmyk.yellow = 0;
theColor.cmyk.black = 0;
var theCh = activeDocument.channels.add();
theCh.kind = ChannelType.SPOTCOLOR;
theCh.name = "test1";
theCh.opacity = 50;
theCh.color = theColor;
activeDocument.activeLayer.invert();
}
if(win.pnl1.rb2.value){
//Checkbox 2
var theColor = new SolidColor();
theColor.cmyk.cyan = 50;
theColor.cmyk.magenta = 0;
theColor.cmyk.yellow = 50;
theColor.cmyk.black = 0;
var theCh = activeDocument.channels.add();
theCh.kind = ChannelType.SPOTCOLOR;
theCh.name = "test2";
theCh.opacity = 50;
theCh.color = theColor;
activeDocument.activeLayer.invert();
}
if(win.pnl1.rb3.value){
//Checkbox 3
var theColor = new SolidColor();
theColor.cmyk.cyan = 50;
theColor.cmyk.magenta = 50;
theColor.cmyk.yellow = 0;
theColor.cmyk.black = 0;
var theCh = activeDocument.channels.add();
theCh.kind = ChannelType.SPOTCOLOR;
theCh.name = "test3";
theCh.opacity = 50;
theCh.color = theColor;
activeDocument.activeLayer.invert();
}
}
win.center();
win.show();
}
Copy link to clipboard
Copied
You code Dialog using Adobe ScriptUI. The documentation is in the manual JavaScript-Tools-Guide-CC.pdf

Get ready! An upgraded Adobe Community experience is coming in January.
Learn more