How to make invisible button that turns into button with text and backround color

New Here ,
Aug 04, 2022 Aug 04, 2022

Copy link to clipboard

Copied

Hey!

 

I got image that have been printscreened. Image has "button" which I want turn in real button. This button should be as it is first and if pressed it should turn out same sized button with custom text and its own backround color. And if that button is pressed again it should be back at its "invisible button" state.

Also I want to that this button will make datefield under that button to show current time like "when did button were pressed". 

 

Please help and thank you beforehand!

 

-Jake

TOPICS
How to , JavaScript

Views

59

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
community guidelines
New Here ,
Aug 04, 2022 Aug 04, 2022

Copy link to clipboard

Copied

This is the JS now on my button and it works but I can't get it how to make the text to come over that and also how the current time on another datefield...

event.target.fillColor = (color.equal(color.transparent, event.target.fillColor)) ? color.green : color.transparent;

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
community guidelines
Adobe Community Professional ,
Aug 04, 2022 Aug 04, 2022

Copy link to clipboard

Copied

For "datefield" if thats actual field name use this:

this.getField("datefield").value = new Date();

 

For text, you want text in another button or text field and what is name of that field?

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
community guidelines
New Here ,
Aug 04, 2022 Aug 04, 2022

Copy link to clipboard

Copied

Thank you.

For the button I want that invisible button turns into green button with specific text on it. And if pressed again, it turns back as invisible button and also whips datefield empty. Recap: invisible button = nothing shows up, when pressed=> green button with text and current time datefield appears, when pressed again => invisible button and date vanishes

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
community guidelines
Adobe Community Professional ,
Aug 04, 2022 Aug 04, 2022

Copy link to clipboard

Copied

Use this script:

if(color.equal(color.green, event.target.fillColor)){
event.target.fillColor = color.transparent;
event.target.buttonSetCaption("");
this.getField("datefield").value = "";}
else if(color.equal(color.transparent, event.target.fillColor)){
event.target.fillColor = color.green;
event.target.buttonSetCaption("Text goes here");
this.getField("datefield").value = new Date();}

 

Format 'datefield' to the date/time format you wish in 'datefield' properties → format tab.

Remove previous scripts from button field.

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
community guidelines
New Here ,
Aug 04, 2022 Aug 04, 2022

Copy link to clipboard

Copied

OH THANK YOU SO MUCH!!!

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
community guidelines
New Here ,
Aug 04, 2022 Aug 04, 2022

Copy link to clipboard

Copied

Thank you for previous code but now I have some color issue. I try to make some custom coloured buttons but they only change colour but doesn't turn back to invisible and time also doesn't dissappear. Here is the one of the code:

if(color.equal(["RGB", 255/255,181/255,90/255], event.target.fillColor)){
event.target.fillColor = color.transparent;
event.target.buttonSetCaption("");
this.getField("Date1").value = "";}
else if(color.equal(color.transparent, event.target.fillColor)){
event.target.fillColor = ["RGB", 255/255,181/255,90/255];
event.target.buttonSetCaption("Buttontext1");
this.getField("Date1").value = new Date();} 

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
community guidelines
Adobe Community Professional ,
Aug 05, 2022 Aug 05, 2022

Copy link to clipboard

Copied

Comparing RGB colors is a little trickier,

You can try using this: ["RGB", 1,0.709808349609375,0.352935791015625] if it doesn't work from first, try to set color to transparent (No fill) manually and then try.

Try read this:

https://community.adobe.com/t5/acrobat-discussions/script-to-color-change/m-p/13006159 

 

 

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
community guidelines
New Here ,
Aug 05, 2022 Aug 05, 2022

Copy link to clipboard

Copied

Thank you so much again! That one worked and hopefully rest of few colourings works out just like that 😄

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
community guidelines
New Here ,
Aug 05, 2022 Aug 05, 2022

Copy link to clipboard

Copied

First one worked like a charm but rest of buttons didn't....well maybe I just go with this or if you have some another trick how I may get this work out I would be very happy! 🙂

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
community guidelines
Adobe Community Professional ,
Aug 05, 2022 Aug 05, 2022

Copy link to clipboard

Copied

LATEST

Did you run code in JavaScript console as stated in that post?

Post RGB code you want to use.

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
community guidelines