Copy link to clipboard
Copied
Hi there,
I am using this script within my custom keystroke script:
// Custom Keystroke script for dropdown
(function () {
if (!event.willCommit) {
exp_val = event.changeEx;
// Get a reference to the text field
var f = getField("DD39");
// Set the stroke color of the text field based on the dropdown selection
switch (exp_val) {
case "0" :
f.fillColor = color.green;
break;
case "1" :
f.fillColor = color.blue;
break;
case "2" :
f.fillColor = color.yellow;
break;
case "3" :
f.fillColor = color.red;
break;
default :
f.fillColor = color.white;
break;
}
}
})();
However I would really like to use custom color values, rather than the defaults. What is the syntax? I've tried a few things but nothing works.
Thanks
Amanda
Copy link to clipboard
Copied
You should read up about the color object in the Acrobat JS Reference, but basically it's an array with the color space followed by the values, represented by a number from 0 to 1.
For example:
["RGB", 0, 1, 1]
or
["CMYK", 0.14, 0.23, 0, 1]
Copy link to clipboard
Copied
Converting colors to 0-1 is easy for CMYK but not for RGB.
You can use the real RGB values instead : ["RGB", 128/255, 167/255, 99/255]