Mudar de cor ao selecionar um botão

New Here ,
Apr 27, 2020

Copy link to clipboard

Copied

É possivel criar um formulário onde eu possa atribuir uma área que mude de cor ao clicar?

Séria possivel ter uma lista de cores que eu possa escolher para aplicar naquela área?

TOPICS
Acrobat SDK and JavaScript, Edit and convert PDFs, PDF forms

Views

79

Likes

Translate

Translate

Report

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

Mudar de cor ao selecionar um botão

New Here ,
Apr 27, 2020

Copy link to clipboard

Copied

É possivel criar um formulário onde eu possa atribuir uma área que mude de cor ao clicar?

Séria possivel ter uma lista de cores que eu possa escolher para aplicar naquela área?

TOPICS
Acrobat SDK and JavaScript, Edit and convert PDFs, PDF forms

Views

80

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 27, 2020 0
Most Valuable Participant ,
Apr 27, 2020

Copy link to clipboard

Copied

Sure, you can do that with a button field. Do you mean that you want it to change from one color to another each time you click it, like a "traffic light" (red to yellow to green to red, etc.)?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 27, 2020 0
New Here ,
Apr 28, 2020

Copy link to clipboard

Copied

Yes, that's right. How can I do that?
I looked for tutorials on the Internet but I couldn't find them.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 28, 2020 0
try67 LATEST
Most Valuable Participant ,
Apr 28, 2020

Copy link to clipboard

Copied

Sure, here's an example. Create a button with a red (RGB 1,0,0) fill color and then set the following as its MouseUp JavaScript code:

 

var colors = [color.red, color.yellow, color.green];

for (var i=0; i<colors.length; i++) {
	if (color.equal(event.target.fillColor, colors[i])) {
		event.target.fillColor = (i==colors.length-1) ? colors[0] : colors[i+1];
		break;
	}
}

Each time you click it it will switch to the next color in the colors array, which can be as long as you wish.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 28, 2020 1