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

Button Color Change on Hover and Exit

Community Beginner ,
Nov 09, 2023 Nov 09, 2023

Hi,

I searched this forum but couldn't find an answer to my inquiry. I have a Adobe form with a button that I want to change color when the user hovers over it (MouseEnter) and changes color back when the user no longer hovers over it (MouseExit). The button default RGB color is set as 0,0,255. The following Javascript doesn't seem to work. Am I doing something wrong? Thank you!

 

Mouse enter

event.target.fillColor = (color.equal(["RGB", 0/255,0/255,255/255], event.target.fillColor)) ? ["RGB", 240/255,255/255,255/255] : ["RGB", 0/255,0/255,255/255];

 

Mouse exit

event.target.fillColor = (color.equal(["RGB", 240/255,255/255,255/255], event.target.fillColor)) ? ["RGB", 0/255,0/255,255/255] : ["RGB", 240/255,255/255,255/255];

TOPICS
JavaScript , PDF forms
877
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
1 ACCEPTED SOLUTION
Community Expert ,
Nov 10, 2023 Nov 10, 2023

This type of comparison won't work. But there's is no reason to do it anyway.

Use this: 

 

Mouse enter

event.target.fillColor = ["RGB", 240/255,1,1];

 

Mouse exit

event.target.fillColor =  ["RGB", 0,0,1] ;

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

View solution in original post

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 ,
Nov 09, 2023 Nov 09, 2023

Using custom colors with fractional values is very tricky as they can be adjusted behind the scenes to something else, and then the comparison will fail. I suggest using something else, like the field's tooltip.

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 ,
Nov 10, 2023 Nov 10, 2023

This type of comparison won't work. But there's is no reason to do it anyway.

Use this: 

 

Mouse enter

event.target.fillColor = ["RGB", 240/255,1,1];

 

Mouse exit

event.target.fillColor =  ["RGB", 0,0,1] ;

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 Beginner ,
Nov 13, 2023 Nov 13, 2023
LATEST

Great, this worked! Thank you.

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