Copy link to clipboard
Copied
I am trying to create a function that will clear the icon for all group fields except the selected one, and choose another for the selected one.
I created button fields and gave them a certain icon. They are named Button.check#0 - Button.check#3.
For instance, when the user will click on +1 (Button.check#1), the +1 button will have the circle icon, and the others will become empty icons, so that the +1 is "marked" for the user. If the user then presses +2 (Button.check#2), the icon there will change and the icon for +1 will clear.
I believe the correct functions to use are buttonGetIcon() and buttonSetIcon() but I have no idea how to utilize them for what I need.
Any ideas how this can be done?
Thank you!
Copy link to clipboard
Copied
I would use an overlapping matching button with an icon that doesn't have the circle, and then show/hide the fields when needed. Otherwise you'll have to deal with hidden fields that hold the icons for each button, so you could set it back again, and it would become a mess.
If you do it with the double set of buttons all you have to do when one of them is clicked is:
- Hide that field
- Show the matching field
- If the version with the circle is shown, hide all other circle versions (for the other fields in the group) and show the non-circle versions.
Copy link to clipboard
Copied
But how do I do that? How do I create a "matching" button?
Copy link to clipboard
Copied
Duplicate the fields you already created, rename them from "Button.check" to "Button.no_check" (for example), change their icons to the non-circle version of the image, and hide them.
Copy link to clipboard
Copied
Still not sure what to do.
Is there anywhere I can find the definition of functions with their possible input and output values etc.?
For example the "setButtonIcon", can I just put a URL for an image from the web?
Where can I read how these functions work?
Copy link to clipboard
Copied
Sure, it's all in the "JavaScript for Acrobat API Reference", which is a part of the Acrobat SDK.
And no, you can't load an image from a URL.
Copy link to clipboard
Copied
PS. It's not setButtonIcon, but buttonSetIcon...
Copy link to clipboard
Copied
I've been trying to see how I can utilize the answers from here: Solved: Buttons change and Javascript - Adobe Support Community - 12399260
But I think I'm missing some vital information to make it work.
How can I get the icon of the button that currently has the icon on it and not "clear"? And how can I just clear an icon using setButtonIcon?
I tried with this simple code but leaving the function empty doesn't seem to work:
function setLabelDanger () {
event.target.buttonSetIcon();
}
setLabelDanger();
Copy link to clipboard
Copied
How do I know which button is selected from the group? And how do I select its "duplicate"?
Copy link to clipboard
Copied
Because that's the field that triggers the event. You can access it via event.target.name.
This is not a trivial task, if you don't have any experience with Acrobat JavaScript. If you're interested in hiring a professional to create it for you, feel free to contact me privately by clicking my user-name and then on "Send a Message".