简体   繁体   中英

Adobe Acrobat toggle button - show/hide field

What I want is a button in Acrobat that would hide a field if it's visible and show it if it's hidden, alternatively.

I know there is a way to do one or the either on MouseUp, but I want to do both using the same button.

This where I got so far:

var Strikethrough = this.getField("text_strikethrough");
if(Strikethrough.display = display.hidden){Strikethrough.display = display.visible
} else {Strikethrough.display = display.hidden}

Unfortunately, it doesn't seem to be working.

Any help would be appreciated.

It is correct behavior… the shortcuts "display.hidden" or "display.visible" are honored only when setting, not when getting.

Instead you use the codes for which "display.hidden" or "display.visible" stand. You can get them easily by setting the option for a field, and then use the Console to return the code.

However, for brevity's sake, here are the codes:

0: visible
1: hidden
2: noPrint
3: noView

When you test for these codes, your script should work.

Try the following:

var Strikethrough = this.getField("text_strikethrough");
if(Strikethrough.display == display.hidden){Strikethrough.display = display.visible
} else {Strikethrough.display = display.hidden}

I used '==' instead of '=' in the "if condition".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM