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

Create an action for a button on click event

Community Beginner ,
Nov 20, 2012 Nov 20, 2012

Hi,

I am newbie on indesign. I like to know how to add  a simple javascript to a button on click event.

I like to have control on click event to hide or show layers.

In Acrobat the following javascript will work to toggle the visibility of a layer called layer1. Is it the same for indesing?

var docOCGs = this.getOCGs();

for (var x=0; x < docOCGs.length; x++)

{

if(docOCGs.name == "layer1")

{

  docOCGs.state = !docOCGs.state;

}

}

thanks

TOPICS
Scripting
1.4K
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 20, 2012 Nov 20, 2012
LATEST

Do not confuse "PDF events" (clicking a button, showing/hiding layers) with "InDesign events" (which are things that happen inside InDesign only, when working on an InDesign document).

If InDesign runs a script, it changes the state of the InDesign document. You can add buttons to an InDesign document but those would not "do" something inside InDesign, because the button behavior is only visible in an exported PDF. Similar, you cannot write an InDesign Javascript to "do" something when clicked in the exported PDF -- it's a different level.

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