Copy link to clipboard
Copied
I want to Select Black And its show Black in Dropdown menu, when i click dropdown menu its show red only---
Step 1:- I Select Black in Drop Down Menu
Step 2:- Alert:- You have selected Black
My If condition is not satisfied, How to put right condition of if
var dlgMain = new Window("dialog","CCCCCCC", undefined, { closeButton:true} )
dlgMain.marginLeft = 15;
dlgMain.center();
dlgMain.orientation = "row";
var dropdown7_array = ["Black","Red","White","Blue","Green"];
var dropdown7 = dlgMain.add("dropdownlist", undefined, undefined, {name: "dropdown7", items: dropdown7_array});
dropdown7.selection = 0;
dlgMain.show();
if(dropdown7.selection==dropdown7.items);
{
alert("red");
}
I extended my code of .text, so now you can use conditions to check chosen color name.
Copy link to clipboard
Copied
Over dlgMain.show(); put this code line:
dropdown7.onChange = function() {alert(this.selection)}
Ps. you may also remove your code from beyond dlgMain.show();
Copy link to clipboard
Copied
Thanku so much It Worked...
But I Select Black , It's show me you have selected Black
var dlgMain = new Window("dialog","CCCCCCC", undefined, { closeButton:true} )
dlgMain.marginLeft = 15;
dlgMain.center();
dlgMain.orientation = "row";
var dropdown7_array = ["Black","Red","White","Blue","Green"];
var dropdown7 = dlgMain.add("dropdownlist", undefined, undefined, {name: "dropdown7", items: dropdown7_array});
dropdown7.selection = 0;
dropdown7.onChange=function()
{
if(this.selection=="Black")
{
alert("You have Selected Black");
}
if(this.selection=="Red")
{
alert("You have Selected Red");
}
}
dlgMain.show();
/* if(dropdown7.selection
Copy link to clipboard
Copied
Step back to your original code and instead of code line from my previous post use this one:
dropdown7.onChange=function(){alert('You\'ve Selected '+this.selection.text)}
Copy link to clipboard
Copied
You code is right but my question is not understand you have !
Step 1:- I Select Black :-
var strokeColorB = new RGBColor();
strokeColorB.hexValue = '000000';
Step 2:- I Select White Again:-
var strokeColorW = new RGBColor();
strokeColorW.hexValue = 'ffffff';
I want to condition of if in dropdown menu
Copy link to clipboard
Copied
I extended my code of .text, so now you can use conditions to check chosen color name.
Copy link to clipboard
Copied
Yes @Kukurykus Right Answar @!
Thanku so much @Kukurykus
Copy link to clipboard
Copied
Alternatively you can play with:
sc = new SolidColor()
clrs = {0: '000000', 1: 'ff0000', 2: 'ffffff', 3: '0000ff', 4: '00ff00'}
dropdown7.onChange = function() {sc.hexValue = clrs[this.selection.index]}
Copy link to clipboard
Copied
Wow @Kukurykus You are great for knowledge !
Copy link to clipboard
Copied
Can you modify the code :-
var st = new RGBColor()
st.hexValue = '000000';
clrs = {0: '000000', 1: 'ff0000', 2: '00ff30', 3: '0024ff', 4:'ff00f0',5:'fff600'}
dropdown4.onChange = function()
{st.hexValue = clrs[this.selection.index]}
Getting a error !
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Getting a Error :- "Required Value is missing"
TextLayer("Photoshop");
var st = new RGBColor()
st.hexValue = '000000';
clrs = {0: '000000', 1: 'ff0000', 2: '00ff30', 3: '0024ff', 4:'ff00f0',5:'fff600'}
dropdown4.onChange = function()
{st.hexValue = clrs[this.selection.index]}
function TextLayer(text) {
var layers = app.activeDocument.artLayers;
var layer = layers.add();
layer.kind = LayerKind.TEXT;
var textItem = layer.textItem;
//textItem.kind = TextType.PARAGRAPHTEXT;
textItem.size = 18;
//textItem.position = [20, 500];
myColor = new SolidColor
myColor.rgb.red = 255
myColor.rgb.green = 0
myColor.rgb.blue = 0
textItem.color=st;
textItem.contents = text;
// textItem.width = new UnitValue(" 100 pixels");
//textItem.height = new UnitValue("30 pixels");
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Here is full code
/*
Code for Import https://scriptui.joonas.me — (Triple click to select):
{"activeId":2,"items":{"item-0":{"id":0,"type":"Dialog","parentId":false,"style":{"enabled":true,"varName":null,"windowType":"Dialog","creationProps":{"su1PanelCoordinates":false,"maximizeButton":false,"minimizeButton":false,"independent":false,"closeButton":true,"borderless":false,"resizeable":false},"text":"NNNNNN","preferredSize":[0,0],"margins":16,"orientation":"column","spacing":10,"alignChildren":["center","top"]}},"item-2":{"id":2,"type":"DropDownList","parentId":0,"style":{"enabled":true,"varName":null,"text":"DropDownList","listItems":"Black,Pink,Blue,Red","preferredSize":[0,0],"alignment":null,"selection":0,"helpTip":null}}},"order":[0,2],"settings":{"importJSON":true,"indentSize":false,"cepExport":false,"includeCSSJS":true,"showDialog":true,"functionWrapper":false,"afterEffectsDockable":false,"itemReferenceList":"None"}}
*/
// DIALOG
// ======
var dialog = new Window("dialog");
dialog.text = "NNNNNN";
dialog.orientation = "column";
dialog.alignChildren = ["center","top"];
dialog.spacing = 10;
dialog.margins = 16;
var dropdown1_array = ["Black","Pink","Blue","Red"];
var dropdown4 = dialog.add("dropdownlist", undefined, undefined, {name: "dropdown4", items: dropdown1_array});
dropdown4.selection = 0;
dialog.show();
TextLayer("Photoshop");
var st = new SolidColor
st.hexValue = '000000';
clrs = {0: '000000', 1: 'ff0000', 2: '00ff30', 3: '0024ff', 4:'ff00f0',5:'fff600'}
dropdown4.onChange = function()
{st.hexValue = clrs[this.selection.index]}
function TextLayer(text) {
var layers = app.activeDocument.artLayers;
var layer = layers.add();
layer.kind = LayerKind.TEXT;
var textItem = layer.textItem;
//textItem.kind = TextType.PARAGRAPHTEXT;
textItem.size = 18;
//textItem.position = [20, 500];
textItem.color=st;
textItem.contents = text;
// textItem.width = new UnitValue(" 100 pixels");
//textItem.height = new UnitValue("30 pixels");
}
I want to change the Text Color in Dropdown menu
Copy link to clipboard
Copied
The st variable must be declared before calling dialog.show().
You also need to use st.rgb, not just st
var dialog = new Window("dialog");
dialog.text = "NNNNNN";
dialog.orientation = "column";
dialog.alignChildren = ["center","top"];
dialog.spacing = 10;
dialog.margins = 16;
var dropdown1_array = ["Black","Pink","Blue","Red"];
var dropdown4 = dialog.add("dropdownlist", undefined, undefined, {name: "dropdown4", items: dropdown1_array});
dropdown4.selection = 0;
var st = new SolidColor
st.rgb.hexValue = '000000';
clrs = {0: '000000', 1: 'ff0000', 2: '00ff30', 3: '0024ff', 4:'ff00f0',5:'fff600'}
dropdown4.onChange = function()
{st.rgb.hexValue = clrs[this.selection.index]}
dialog.show();
TextLayer("Photoshop");
function TextLayer(text) {
var layers = app.activeDocument.artLayers;
var layer = layers.add();
layer.kind = LayerKind.TEXT;
var textItem = layer.textItem;
//textItem.kind = TextType.PARAGRAPHTEXT;
textItem.size = 18;
//textItem.position = [20, 500];
textItem.color=st;
textItem.contents = text;
// textItem.width = new UnitValue(" 100 pixels");
//textItem.height = new UnitValue("30 pixels");
}
Copy link to clipboard
Copied
Yes i have used st.rgb But getting "internal error"
var dialog =new Window("dialog");
dialog.text = "NNNNNN";
dialog.orientation = "column";
dialog.alignChildren = ["center","top"];
dialog.spacing = 10;
dialog.margins = 16;
var dropdown4_array = ["Black","Pink","Blue","Red"];
var dropdown4 = dialog.add("dropdownlist", undefined, undefined, {name: "dropdown4", items: dropdown4_array});
dropdown4.selection = 0;
var st = new SolidColor
st.rgb.hexValue = '000000';
clrs = {0: '000000', 1: 'ff0000', 2: '00ff30', 3: '0024ff', 4:'ff00f0',5:'fff600'}
dropdown4.onChange = function()
{st.rgb.hexValue = clrs[this.selection.index]}
dialog.show();
TextLayer("Photoshop");
function TextLayer(text) {
var layers = app.activeDocument.artLayers;
var layer = layers.add();
layer.kind = LayerKind.TEXT;
var textItem = layer.textItem;
//textItem.kind = TextType.PARAGRAPHTEXT;
textItem.size = 18;
//textItem.position = [20, 500];
textItem.color=st.rgb;
textItem.contents = text;
// textItem.width = new UnitValue(" 100 pixels");
//textItem.height = new UnitValue("30 pixels");
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I have compared with your code All are right but getting a error, Please check it what is problem ?
var dialog =new Window("dialog");
dialog.text = "NNNNNN";
dialog.orientation = "column";
dialog.alignChildren = ["center","top"];
dialog.spacing = 10;
dialog.margins = 16;
var dropdown4_array = ["Black","Pink","Blue","Red"];
var dropdown4 = dialog.add("dropdownlist", undefined, undefined, {name: "dropdown4", items: dropdown4_array});
dropdown4.selection = 0;
var st = new SolidColor()
st.hexValue = '000000';
clrs = {0: '000000', 1: 'ff0000', 2: '00ff30', 3: '0024ff', 4:'ff00f0',5:'fff600'}
dropdown4.onChange = function()
{st.hexValue = clrs[this.selection.index]}
dialog.show();
TextLayer("Photoshop");
function TextLayer(text) {
var layers = app.activeDocument.artLayers;
var layer = layers.add();
layer.kind = LayerKind.TEXT;
var textItem = layer.textItem;
//textItem.kind = TextType.PARAGRAPHTEXT;
textItem.size = 18;
//textItem.position = [20, 500];
textItem.color=st.rgb;
textItem.contents = text;
// textItem.width = new UnitValue(" 100 pixels");
//textItem.height = new UnitValue("30 pixels");
}
;-
Copy link to clipboard
Copied
I have compared with your code All are right but getting a error, Please check it what is problem ?
By @MXKS
Find three differences
Copy link to clipboard
Copied
Yes, Correct it but same issue
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Check it ,I'm tired to resolve the error !
var dialog =new Window("dialog");
dialog.text = "NNNNNN";
dialog.orientation = "column";
dialog.alignChildren = ["center","top"];
dialog.spacing = 10;
dialog.margins = 16;
var dropdown4_array = ["Black","Pink","Blue","Red"];
var dropdown4 = dialog.add("dropdownlist", undefined, undefined, {name: "dropdown4", items: dropdown4_array});
dropdown4.selection = 0;
var st = new SolidColor()
st.hexValue = '000000';
clrs = {0: '000000', 1: 'ff0000', 2: '00ff30', 3: '0024ff', 4:'ff00f0',5:'fff600'}
dropdown4.onChange = function()
{st.hexValue = clrs[this.selection.index]}
dialog.show();
TextLayer("Photoshop");
function TextLayer(text) {
var layers = app.activeDocument.artLayers;
var layer = layers.add();
layer.kind = LayerKind.TEXT;
var textItem = layer.textItem;
//textItem.kind = TextType.PARAGRAPHTEXT;
textItem.size = 18;
//textItem.position = [20, 500];
textItem.color=st.rgb;
textItem.contents = text;
// textItem.width = new UnitValue(" 100 pixels");
//textItem.height = new UnitValue("30 pixels");
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Ok @r-bin Thanku so much , Code is worked fine
Copy link to clipboard
Copied
To avoid spamming next time link a post with a code you once published in exact same shape.