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

How can add a action of button create from script?

Enthusiast ,
Jul 19, 2022 Jul 19, 2022

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.pngexpand image

 

TOPICS
Scripting
712
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

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

...
Translate
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

 

Regards,
Uwe Laubender
( Adobe Community Professional )

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

Thank you @Laubender.

What is Behavior for this Event & Action?

daitranthanhoa_0-1658282746092.pngexpand image

 

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

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