Copy link to clipboard
Copied
I am working on a script to add a frame to my photographs. The UI can be seen here. The checkbox to use hexadecimal values for colors is checked, but when I click the "White" button, decimal numbers are used.
Here is the code initializing the check box:
this.TextColorHex = this.TextColorGroup.add("checkbox", undefined, undefined, {name: "TextColorHex"});
this.TextColorHex.text = "Hex";
this.TextColorHex.checked = false;
alert ("TextColorHex status initialized to " + this.TextColorHex.checked);
I have the dialog box containing this checkbox wrapped into a class, hence the use of "this". I had to explicitly initialize the checked property to "false" because the alert was telling me it was undefined, which surprised me. I expected it to be false by default.
The White button is initialized like this:
this.WhiteButton = this.group2.add("button", undefined, undefined, {name: "WhiteButton"});
this.WhiteButton.text = "White";
this.WhiteButton.tag = this;
this.WhiteButton.addEventListener("click", this.OnWhiteClick)
Putting the dialog object into the button's tag property makes it available in the event handler, which looks like this:
FrameDialog.prototype.OnWhiteClick = function(e)
{
alert ("Hex checkbox status: " + e.target.tag.TextColorHex.checked);
if (e.target.tag.TextColorHex.checked)
{
e.target.tag.TextColorR.text = "ff";
e.target.tag.TextColorG.text = "ff";
e.target.tag.TextColorB.text = "ff";
}
else
{
e.target.tag.TextColorR.text = "255";
e.target.tag.TextColorG.text = "255";
e.target.tag.TextColorB.text = "255";
}
}
But when I click the checkbox to use hex and then click the White button, the alert tells me that the checkbox's check state is False! Why isn't this reporting the true state of the checkbox?
And I found another oddity: when I initialized the checkbox to true, the checkbox did not show a check mark, but the alert just after creating the checkbox reports that the checked state is true!
What is going on with the checkbox? How can I reliably use its state?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thank you. Of course, that was the problem.
The problem with reading the documentation is that I don't have it. I presume that that was from the ExtendScript Tool Kit documentation. I have not been able to find where to download it. The only download links I've found are broken. If you can point me to where I can download it, I'd be forever grateful.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I do not know ScriptUI I just copy paste parts of dialog I fine in script Adobe installed with Photoshop or
ones I have downloaded from the web many from appends made here that work one my machine. Here is a dialogs from my collage populating script. It Has one checkbox I include the Scriptui Dialog statement to add the checkbox and the code the uses the checkbox. I did not have to initialize the checkbox I just declared its variable .st and checked it
dlg.msgPnl.StampImage = dlg.msgPnl.add('group');
dlg.msgPnl.StampImage.orientation = "row";
dlg.msgPnl.StampImage.alignment='left';
dlg.msgPnl.StampImage.st = dlg.msgPnl.StampImage.add('checkbox', undefined, 'Stamp Filename on Image');
dlg.msgPnl.StampImage.helpTip = "Stamp Filename on Image.";
// Add Filename Text if called for
if ( PopCollage.msgPnl.StampImage.st.value) {
stampFilename(textFont,textSizeFactor,textColor,Name);
loadAlpha("Image " + imageNumber);
//var Position = 5;
var Position = Number(PopCollage.msgPnl.grp5a.dd1.selection.index) + 1;
switch (Position){
case 1 : align('AdLf'); align('AdTp'); break;
case 2 : align('AdCH'); align('AdTp'); break;
case 3 : align('AdRg'); align('AdTp'); break;
case 4 : align('AdLf'); align('AdCV'); break;
case 5 : align('AdCH'); align('AdCV'); activeDocument.selection.deselect(); activeDocument.activeLayer.rotate(textAngle); break;
case 6 : align('AdRg'); align('AdCV'); break;
case 7 : align('AdLf'); align('AdBt'); break;
case 8 : align('AdCH'); align('AdBt'); break;
case 9 : align('AdRg'); align('AdBt'); break;
default : break;
}
activeDocument.selection.deselect();
// Add text Layer's layer style
addStyle(textStyle);
// could add code to do something with the image prefix info if it exists in prefixlist
if ( prefixlist[imageNumber -1] != undefined ) {}
}