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

How can add a action of button create from script?

Enthusiast ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

I want create a Button from script.

I had add by script:

var doc=app.documents[0];
var txtMain=doc.textFrames[0];

var oCell_URL=txtMain.tables[0].cells[1];
var btnLink=oCell_URL.buttons.add();

Now, How can add action for this button?

Ex:

daitranthanhoa_0-1658222714503.png

 

TOPICS
Scripting

Views

390

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

correct answers 1 Correct answer

Community Expert , Jul 19, 2022 Jul 19, 2022

Hi @daitranthanhoa ,

look up the DOM documentation for the Button object.

You'll add a gotoURLBehavior to the button object.

Sample code:

 

var doc = app.documents.add();
var myButton = doc.buttons.add({ geometricBounds : [0,0,"50mm","50mm"]});
myButton.gotoURLBehaviors.add
(
	{
		behaviorEvent : BehaviorEvents.MOUSE_DOWN ,
		enableBehavior : true ,
		url : "http://adobe.com"
	}
);

 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Button.html

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#GotoURLBehavior.html

...

Votes

Translate

Translate
Community Expert ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

Hi @daitranthanhoa ,

look up the DOM documentation for the Button object.

You'll add a gotoURLBehavior to the button object.

Sample code:

 

var doc = app.documents.add();
var myButton = doc.buttons.add({ geometricBounds : [0,0,"50mm","50mm"]});
myButton.gotoURLBehaviors.add
(
	{
		behaviorEvent : BehaviorEvents.MOUSE_DOWN ,
		enableBehavior : true ,
		url : "http://adobe.com"
	}
);

 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Button.html

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#GotoURLBehavior.html

 

Regards,
Uwe Laubender
( Adobe Community Professional )

Votes

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
Enthusiast ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

Thank you @Laubender.

What is Behavior for this Event & Action?

daitranthanhoa_0-1658282746092.png

 

Votes

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
Community Expert ,
Jul 20, 2022 Jul 20, 2022

Copy link to clipboard

Copied

LATEST

Try the ShowHideFieldsBehavior. Look it up in the DOM documentation:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#ShowHideFieldsBehavior.html#d1e186415

 

Regards,
Uwe Laubender
( Adobe Community Professional )

Votes

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