Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Dialog box with check boxes in Photoshop CS6, javascript

Participant ,
Apr 05, 2018 Apr 05, 2018

Hi,

I need to create dialog box to allow user to pick from selection of check boxes in Photoshop CS6, javascript.

Thank you.

Yulia

TOPICS
Actions and scripting
3.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Apr 07, 2018 Apr 07, 2018

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

...
Translate
Adobe
Community Expert ,
Apr 05, 2018 Apr 05, 2018

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.

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 05, 2018 Apr 05, 2018

Yes, I need user to be able to make multiple selections.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 05, 2018 Apr 05, 2018

Is there a problem in your CS6 where check boxes do not work correctly? Post your script...

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 05, 2018 Apr 05, 2018

I don't have it yet, I need one. The user will be adding multiple spot channels to the artwork.

Thank you

Yulia

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 06, 2018 Apr 06, 2018

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 07, 2018 Apr 07, 2018

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();

}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 07, 2018 Apr 07, 2018

Thank you, this is great. Will it allow the user to choose more than one color at the time?

Yulia

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 07, 2018 Apr 07, 2018
LATEST

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();

}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 06, 2018 Apr 06, 2018

You code Dialog using  Adobe ScriptUI.  The documentation is in the manual JavaScript-Tools-Guide-CC.pdf

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines