The class provides methods to deal with interctive objects like push buttons, multi state objects, text fields and so on.

Version :
12.03.2024, 15:56 Uhr

The class provides methods to deal with interctive objects like push buttons, multi state objects, text fields and so on.

Here you will find three test documents:

Copy inter3.w2lm to your desktop, then you can have the PDF generated by comet_pdf with the following line:

comet_pdf -i \$DESKTOP/inter3.w2ml --interactive 1 -L

Interactive objects are used in interactive PDFs and in folios generated by InDesign®. The following interactive objects are supported by InDesign®.
Value Constant Short Description
0 kMultistate State objek, not supported by comet_pdft
1 kPushbutton Button
2 kTextfield Text edit field
3 kCheckbox Check box
4 kRadiobutton Radio button
5 kListboxfield List field
6 kCombobox Combo box
7 kSignature Signature field

The state of an object defines, how the object looks like. In the screenshot you can see a check box with several faces:



Only buttons, check boxes and radio buttons can have a state. The following table shows all avaible states for interactive objects:
Value Constant Used in
-1 kStateInvalid Invalid or unknown state
0 kStateNormal button
1 kStateOver
2 kStateDown
3 kStateNormalOn check box, radio button
4 kStateNormalOff
5 kStateOverOn
6 kStateOverOff
7 kStateDownOn
8 kStateDownOff
0 kStateFirst Usefull for loops
8 kStateLast

Illustrator® does not provide interactive objects. The functions of the module interactive therefore have no meaning in Illustrator®.

Please note that comet_pdf must be started with the \URL [option --interactive N]{../InDesign/Plugins/comet_pdf.html#interactive} to create an interactive PDF. If the option is missing, the interactive elements of the document are not exported to the PDF.

Interactive objects may receive the following events:
Value Constant Notes
-1 kNoEvt
0 kAnyEvt
1 kMouseUpEvt InDesign® standard
2 kMouseDownEvt
3 kMouseEnterEvt
4 kMouseExitEvt
5 kOnFocusEvt
6 kOnBlurEvt
7 kOpenEvt See here
8 kCloseEvt
9 kVisibleEvt
10 kInvisibleEvt
11 kActivateEvt
12 kCalculateEvt
13 kFormatEvt
14 kKeystrokeEvt
15 kValidateEvt

Interactive elements can have different options in the exported PDF. In the lower part of the panel Formfields and Buttons (see above), these options can be set.

A number of important options used by PDF viewers such as Adobe Acrobat can not be set in InDesign®. As a workaround we create Frame Labels to define these data. comet_pdf can read these properties and set them in the target document. To set the values, open the panel Frame Labels and select the desired Form area. With the + button of the panel you now can set the properties. The corresponding descriptions can be found at the end of the following table.

Again, these settings have no effect on PDFs exported directly from InDesign®.

The following table shows all options supported by set_pdf_option and get_pdf_option. The options defined in frame labels can be edited by the help of panel Frame Labels in additions (see column 4 of following table).

Wert Konstante Type Bemerkung
0 kPDFPrintVisible bool (0 | 1) Visibility. Default is visible everywhere

until v4.2 R33133
0 : no print
sonst : visible everywhere


0: no print
1 : isible everywhere
2 : hidden
3 : noview

Unfortunately, InDesign® treats the visibility as a bool value only and can support the values 0 and 1 therefore only. Instead of 2 or 3, the value 0 (no print) is automatically set here. So to set the visibility of an interactive field in PDFs created by comet_pdf to hidden or no view, the property must be set directly by comet_pdf.
1 kPDFRequired required fiels of PDF
2 kPDFPassword Use bullet points or stars for writing
3 kPDFReadonly
4 kPDFMultiline
5 kPDFScrollable Scrollbar is shown, if the text exceeds the frame
6 kPDFTaborder int Tab order. In InDesign® you can define the tab order using the menu Object -> Interactiv -> Set Tab Order.
7 kPDFArticleorder not implemented
8 kPDFFontsize float
9 kPDFTooltip String/char*
10 kPDFFieldValue Button value
11 kPDFCheckedByDefault int Selected by default
12 kPDFFontname String/char*

Font and font color. The font is given as a comma separated pair of font name and face (e.g. "Arial Narrow, Italic").

If you specify a font, a font size (kPDFFontsize) must also be specified!

The color is specified as the name of an existing color field.

13 kPDFFontcolor
14 kPDFListAllowMultipleint Listboxes only

Multiple selection possible?
15 kPDFListEditable Comboboxes only

Is the field editable, or, in other words: Can own values be entered?
16 kPDFListSort List fields only Sort list values?
17 kPDFListValues StringList List fields only Entries of list
18 kPDFDefaultValue String/char* The value is shown when opening the document and after resetting the form fields.
30 kPDFFieldName String/char*

Name of the field. The names must be unique. Only radio buttons that belong to the same group are given the same name. The name can be used in Javascripts to address the form field.

this.getField ('name');

Values supported by frame labels. The 4th column describes the key/value pairs of these labels.
19 kPDFUnionSelect int

priint_FormField_UnionSelect
0 | 1

If the value is equal to 1, radio buttons with the equal button value (kPDFFieldValue) are selected at the same time.

20 kPDRichText int

priint_FormField_RichText
0 | 1

Text formatting allowed. The specification is only allowed in text fields with RGB text colors.

21 kPDFMaxChar int

priint_FormField_MaxChar
>= 0

Permitted maximum number of characters in the text field. Use 0 for unlimited.

22 kPDFCalcOrder int

priint_FormField_CalcOrder
>= 0

Calculation sequence of the fields. The value is only used if the form field has a calculation (kCalculateEvt). Default is 10 plus the maximum CalcOrder used in the cuurent the page.

23 kPDFSpellCheck int

priint_FormField_SpellCheck
0 | 1

Enable spell checking in the text box.

24 kPDFCaption String/char*

priint_FormField_Caption
any text

Labelling of pushbuttons

25 kPDFCaptionRollover String/char*

priint_FormField_CaptionRollover
any text

Text on roll overs. The specification is ignored by Acrobat.

26 kPDFCaptionDown String/char*

priint_FormField_CaptionDown
any text

Text on mouse clicks. The specification is ignored by Acrobat.

27 kPDFFileSelect int

priint_FormField_FileSelect
0 | 1

Here is the official description from Adobe :

Allows the user to enter a file path as the field’s value when a file is submitted along with the form. This option is available only when Scroll Long Text is the only selected option in the Options tab.

But for this to work, you need to write Javascripts. You can find more information on the Internet, we do not further support this option.

28 kPDFBorderStyle String/char*

priint_FormField_BorderStyle
solid | beveled | dashed int int | inset | underline

Border style of push buttons, checkboxes and radio buttons.

The color and thickness of the borders are taken from the settings of the InDesign® object. Please note, that form fields can only have integer frame thicknesses. Other values the border thickness are rounded up accordingly.

The dashed can be extended by two int-numbers : the length of the strokes and the length of the gaps in points. We pass this information to the PDF - but Acrobat always uses 3, 3 anyway.

29 kPDFButtonStyle String/char*

priint_FormField_ButtonStyle
check | cross | diamond | circle | star | square

Which character is shown when checkboxes and radiobuttons are activated?

The color of the frame edge is used as drawing color.

Action may perform several tasks. The table shows a complete list of tasks available for actions:
Wert Konstante Beschreibung Bemerkungen
1 kGoToAnchor Go to destination
2 kGoToFirstPage Go to first page
3 kGoToLastPage Go to last page
4 kGoToNextPage Go to next page
5 kGoToPreviousPage Go to previous page
6 kGoToURL Go to URL
7 kShowHideFields Show/Hide buttons and forms
8 kSound Sound
9 kMovie Video
10 kAnimation Animation Nur Liquid-HTML5 und SWF
11 kGoToPage Go to page
12 kSwitchToMSOState Go to state
13 kSwitchToNextMSOState Go to next state
14 kSwitchToPrevMSOState Go to previous state
21 kResetForm Clear form Nur PDF
15 kGoToNextView Go to next view
16 kGoToPreviousView Go to previous view
17 kOpenFile Open file
19 kPrintForm Print form, not supported by CS5.5
20 kSubmitForm Submit form, not supported by CS5.5
18 kViewZoom Zoom view
22 kExecJavascript Execute JavaScript See here

There seems to be no way in InDesign® to prepare PDFs for document events like recalculation of fields or similar. This affects both the UI and the SDK for developing plug-ins. To enable you to create Javascript implementations in InDesign® as well, we have introduced the priint_FormField_Actions frame label. Open the panel Frame Labels for this purpose. There you can create new key/value pairs using the + button. Give the new entry the key name priint_FormField_Actions . In the value field enter the action(s) including the Javascript.

The syntax of the value is as follows:

event-id task-id "what ever you want"

Any number of actions are possible. The actions are executed in the order of their definition. Here you can find a documetation of the Acrobat JavaScript APIs from Adobe.

Please note that the corresponding functions have no effect for PDFs exported directly from InDesign®.

The example shows an alert box when a button is clicked.

1 := Event kMouseUpEvt
22 := Task kExecJavascript

priint_FormField_Actions
1 22 "alert ('Hallo Paul');"

Calculate the value of a field as the sum of the values of other fields.

12 := Event kCalculateEvt
22 := Task kExecJavascript

priint_FormField_Actions
12 22 "event.value = this.getField ('t1').value + this.getField ('t2').value + this.getField ('t3').value;"

Two actions are defined : Calculate the 19% VAT included in a price and display the result with two decimal places.

12 := Event kCalculateEvt
13 := Event kFormatEvt
22 := Task kExecJavascript

priint_FormField_Actions
12 22 "event.value = this.getField ('t6').value - this.getField ('t6').value / 1.19"
13 22 "event.value = Number (event.value).toFixed(2);"

There seems to be no possibility in InDesign® to default values for form fields. To enable you to make the corresponding settings in InDesign®, we have introduced the frame label priint_FormField_DefaultValue: Please open the Frame Labels panel for this purpose. There you can create new key/value pairs using the + button. Give the new entry the key name priint_FormField_DefaultValue and enter the desired default.

Attention: For lists and combo boxes it is very important that the default (in exactly the given notation) also occurs in the list values. Non-existing defaults cause comet_pdf to abort during PDF creation in case of non-existing list entries!

int is_multistate(ItemRef frameRef)

Does the frame have a multistate object?

Name Type Default Description
Return int   0 : No
1 : Yes, the object is a multi state or part of of a multi state
frameRef ItemRef - Valid reference to a frame or interactive objekt

Version 4.0.5 R11820, 28. Jun 2016

priint:comet InDesign® Plug-Ins, comet_pdf

get
is_formfield

int is_formfield(ItemRef frameRef)

Does the frame have a formfield object (but is not a multistate)?

Formfiels are all alle interactive objects except the object states (multi states).

Name Type Default Description
Return int   0 : No
1 : Yes, the object is form field or part of of a form field
frameRef ItemRef - Valid reference to a frame or interactive objekt

Version 4.0.5 R11820, 28. Jun 2016

priint:comet InDesign® Plug-Ins, comet_pdf

get
is_formfield

static int create(
  ItemRef resref,
  ItemRef frameRef,
  int type = 2,
  char* name = 0,
  int rmvAddits = 0)

Create a new interactive object from an existing frame.

Name Type Default Description
Return int   0 or ErrorCode
resref ItemRef - On successful return it contains the new created states object (may be 0, but if not 0, it must be allocated using item::alloc)
frameRef ItemList - Frame to convert to an interactive object

0 : Current script frame
type int kTextfield Object type, see here
name String/char* 0 Name of new object

The names of interactive fields must be unique! To create unique names, you can use the frame UID, for example:
sprintf (name, "UID%d", item::getint (frameRef));
rmvAddits int 0 In radio buttons and check boxes InDesign® automatically creates a black mark for the active state. Shall I remove it?

0 : No
1 . Yes

Using comet_pdf, this option is ignored.
#include "internal/types.h"

Create a button from the current frame (or - under comet_pdf - the frame with UID 227). If you click the button, a message is shown.

#include "internal/types.h"
int main () { ItemRef fr = item::alloc (); ItemRef mso = item::alloc (); ItemRef action = item::alloc ();
if (system::version () == -1) item::define (fr, 0, 227); else item::define (fr, 0, item::getint (gFrame));
interactive::create (mso, fr, kPushbutton, "123"); interactive::set_pdf_option (fr, kPDFCaption, "My Button"); interactive::set_pdf_option (fr, kPDFCaptionRollover, "My Button Rollover"); interactive::set_pdf_option (fr, kPDFCaptionDown, "My Button Down");
if (system::version () == -1) { interactive::add_action (fr, kMouseUpEvt, kExecJavascript, action); interactive::set_task_data (fr, action, "app.alert('Hallo Paul');"); } else { // Take care to take the *mso* in this case! frame::set_script_tag (mso, "1 22 \"app.alert ('Hello Paul');\"", "priint_FormField_Actions"); }
return 0; }

Version 4.0.5 R11820, 28. Jun 2016

priint:comet InDesign® Plug-Ins, comet_pdf

create_multistate

static int create_multistate(
  ItemRef resref,
  ItemList states,
  char* name = 0)

Create a new multi state object from a given list of objects. Different to interactive::create this function can create a multi state object with more states in one step.

Name Type Default Description
Return int   0 or ErrorCode
resref ItemRef - On successful return it contains the new created states object (may be 0, but if not 0, it must be allocated using item::alloc)
states ItemList - List of states
name String/char* 0 Name of new object, may be 0 or ""

Create an object from the selected frames. The frames are justified at the top left corner of their bounding box.

int main ()
{
    ItemList	frames	= itemlist::selected ();
    ItemList	states 	= itemlist::alloc ();
    ItemRef		mso		= item::alloc ();
    ItemRef		fr		= item::alloc ();
    int			i;
    float		l, t, r, b;
if (gRun > 1) return 0;
if (itemlist::length (frames) == 0) { showmessage ("Please select one or more frames and try again."); return 0; }
if (itemlist::length (frames) > 1) { itemlist::bbox (frames, &l, &t, &r, &b); for (i = 0; i < itemlist::length (frames); i++) { itemlist::get (frames, fr, i); frame::moveto (fr, l, t); } }
interactive::create_multistate (mso, frames, "myname");
return 0; }

Version 4.0.5 R11820, 28. Jun 2016

priint:comet InDesign® Plug-Ins

create

static int resolve(
  ItemRef frameRef,
  int state = -1,
  int doRmv = 0,
  ItemList resultList = 0)

Resolve interactive objects. In the following table you can see, what is done with the frames of interactive objects:< td>Text fields, List fields, Combo boxes, Signatures
Resolve a single state - state >= 0 Resolve all - state kStateInvalid
Type of object doRmv = 0 doRmv = 1 doRmv = 0 doRmv = 1
Multistate Resolved frames are remaining in the document. Relsolve frames are removed. All frames of the multistate are remaining in the document. Same like the flyout menu Release all states to objects of panel Object states. The interactive object and all ots frames are removed.
Buttons, check boxes, radio buttons Only the frames of the active state are remaining in the document, all other frames are removed. Like the button Convert to Object of panel Button and Forms.
No effect The frame of the former interactive object becomes a 'normal' frame again.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid frame reference. If frameRef is not an interactive object, the functions tries to find this object at first.

0 : Current script frame
state int kStateInvalid What to resolve? See above table please.

The state kStateNormal of buttons and kStateNormalOn and kStateNormalOff of radio buttons and check boxes are never resolvable.

Using comet_pdf the parameter has no effect.
doRmv int 0 Remove resolved frames?

0 : No
1 : Yes

See above table please.

Using comet_pdf the parameter has no effect.
outItems ItemList 0 List of resolved and still remaining frames. 0 or alloaceted ItemList.

Using comet_pdf the parameter is left untouched.
#include "internal/types.h"

Version 4.0.5 R11820, 28. Jun 2016

priint:comet InDesign® Plug-Ins, comet_pdf

static int get(
  ItemRef frameRef,
  ItemRef out_mso,
  int* out_state)

Search the interactive object containing a frame. This can be a multi state objects, buttons, text fields, ... . Use item::get_class to find out the objects class.

Name Type Default Description
Return int   0 or ErrorCode

1244 : The frame is not part of an interactive object
frameRef ItemRef - Valid frame reference

0 : current script frame
out_mso ItemRef - allocated ItemRef for the interactive object
out_state int* 0 State containing frameRef, only valid after successful return. In comet_pdf the status always has the value -1.

kStateInvalid The frameRef points to an interactive object itself.

otherwise : State of frame, see here
#include "internal/types.h"
int main ()
{
    ItemRef		mso	= item::alloc ();
    int 		state;
frame::get_interactive (gFrame, mso, &state); showmessage ("MSO : %d\nState : %d\n", item::getint (mso), state);
return 0; }

Version 4.0.5 R11820, 28. Jun 2016

priint:comet InDesign® Plug-Ins, comet_pdf

item::get_class

static int set_pdf_option(
  ItemRef frameRef,
  int type,
  int value)

Set PDF options of an interactive object.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid frame reference. If frameRef is not an interactive object, the functions tries to find this object at first.

0 : Current script frame
typ int - Option to change, see here
value int, float, String/char* - New value of option. The data type of the value depends on the type of option, see here. Take care! Wrong data types may crash InDesign®!
#include "internal/types.h"
#include "internal/types.h"
int main () { ItemRef mso = item::alloc (); ItemRef fr = item::alloc (); int ival; char sval [512];
interactive::create (mso, gFrame, kTextfield, "Paul 1");
interactive::set_pdf_option (gFrame, kPDFTooltip, "Helpless, helpless, helpless"); interactive::get_pdf_option (gFrame, kPDFTooltip, sval, 511); wlog ("", "Tooltip (%s)\n", sval);
interactive::set_pdf_option (gFrame, kPDFCheckedByDefault, 1); interactive::get_pdf_option (gFrame, kPDFCheckedByDefault, &ival); wlog ("", "Checked by default (%d)\n", ival);
interactive::set_pdf_option (gFrame, kPDFFieldValue, "höpöhöpö"); interactive::get_pdf_option (gFrame, kPDFFieldValue, sval, 511); wlog ("", "Field value (%s)\n", sval);
interactive::set_pdf_option (gFrame, 12, "Geogrotesque"); interactive::get_pdf_option (gFrame, 12, sval, 511); wlog ("", "Font (%s)\n", sval);
interactive::set_pdf_option (gFrame, 13, "Seitenkopf"); interactive::get_pdf_option (gFrame, 13, sval, 511); wlog ("", "Color (%s)\n", sval);
return 0; }

Version 4.0.5 R11820, 28. Jun 2016

priint:comet InDesign® Plug-Ins, comet_pdf

static int get_pdf_option(
  ItemRef frameRef,
  int type,
  int* value)

Get PDF options from an interactive object.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid frame reference. If frameRef is not an interactive object, the functions tries to find this object at first.

0 : Current script frame
typ int - Option to retrieve, see here
value int, float, String/char* - Current value of option. The data type of the value depends on the type of option, see here. Take care! Wrong data types may crash InDesign®!
maxlen int -1 Maximum length, only for char* types
#include "internal/types.h"
#include "internal/types.h"
int main () { ItemRef mso = item::alloc (); ItemRef fr = item::alloc (); int ival; char sval [512];
interactive::create (mso, gFrame, kTextfield, "Paul 1");
interactive::set_pdf_option (gFrame, kPDFTooltip, "Helpless, helpless, helpless"); interactive::get_pdf_option (gFrame, kPDFTooltip, sval, 511); wlog ("", "Tooltip (%s)\n", sval);
interactive::set_pdf_option (gFrame, kPDFCheckedByDefault, 1); interactive::get_pdf_option (gFrame, kPDFCheckedByDefault, &ival); wlog ("", "Checked by default (%d)\n", ival);
interactive::set_pdf_option (gFrame, kPDFFieldValue, "höpöhöpö"); interactive::get_pdf_option (gFrame, kPDFFieldValue, sval, 511); wlog ("", "Field value (%s)\n", sval);
interactive::set_pdf_option (gFrame, 12, "Geogrotesque"); interactive::get_pdf_option (gFrame, 12, sval, 511); wlog ("", "Font (%s)\n", sval);
interactive::set_pdf_option (gFrame, 13, "Seitenkopf"); interactive::get_pdf_option (gFrame, 13, sval, 511); wlog ("", "Color (%s)\n", sval);
return 0; }

Version 4.0.5 R11820, 28. Jun 2016

priint:comet InDesign® Plug-Ins, comet_pdf

static int get_frames(
  ItemRef frameRef,
  ItemList resultList,
  int state = -1)

Get a list of all items (frames or groups) of an states object. To find out the state inside an interactive object of a given frame please use the function get.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid frame reference. If frameRef is not an interactive object, the functions tries to find this object at first.

0 : Current script frame
resultList ItemList - Result list. The list must be intited by itemlist::alloc. The list is cleared on function start.
state int kStateInvalid State to get the frames from:

kStateInvalid : All
otherwise : see here
#include "internal/types.h"

Version 4.0.5 R11820, 28. Jun 2016

priint:comet InDesign® Plug-Ins

get

static int add_frame(
  ItemRef frameRef,
  ItemRef addThis,
  int state = -1,
  int replace = 0)

Add a frame or group to a state of an interactive object.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid frame reference. If frameRef is not an interactive object, the functions tries to find this object at first.

0 : Current script frame

Attention: If you replace a state frame, you may remove exactly this frame. Therefor we strongly recommend to use the reference to interactive object here rather than any of its state frames! Use interactive::get to get the reference to the interactive object.
addThis ItemRef - Valid frame or group reference to add.
state int kStateInvalid State to add the frame to. You have to care care on the objeects type:

State object (Multistate):
-1 : Add as new state
otherwise : 0-based index of state.(If too big, a new state is created.)

Buttons, Radio-Buttons, Checkboxes:
Valid state, see here.

Other:
It is not allowed to replace frames here.
replace int 0 Remove old frames of state?

0 : No
1 : Yes
#include "internal/types.h"

Version 4.0.5 R11820, 28. Jun 2016

priint:comet InDesign® Plug-Ins

static int get_actions(
  ItemRef frameRef,
  int eventType,
  ItemList actions)

Get a list of (all) actions of a interactive object.

Multi state objects does NOT have actions!

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid frame reference. If frameRef is not an interactive object, the functions tries to find this object at first.

0 : Current script frame
eventType int - Type of event, see table events.
actions ItemList - Allocted list for results or 0.

For state objects and normal frames the result list is empty.
#include "internal/types.h"
#include "internal/types.h"
int main () { ItemList actions = itemlist::alloc (); ItemRef action = item::alloc (); int e, i;
if (gRun > 1) return 0;
interactive::get_actions (gFrame, kAnyEvt, actions); wlog ("", "%d actions in object %d\n",   itemlist::length (actions),   item::getint (gFrame));
for (e = kMouseUpEvt; e < kValidateEvt; e++) { interactive::get_actions (gFrame, e, actions); wlog ("", " %d actions of type %d in object %d\n",   itemlist::length (actions),   e,   item::getint (gFrame)); }
interactive::get_actions (gFrame, kAnyEvt, actions); for (i = 0; i < itemlist::length (actions); i++) { itemlist::get (actions, action, i); wlog ("", "Action %d with UID %d is triggered by event %d\n",   i,   item::getint (action),   interactive::get_event (gFrame, action)); }
return 0; }

Version 4.0.5 R11820, 28. Jun 2016

priint:comet InDesign® Plug-Ins, comet_pdf

static int count_actions(ItemRef frameRef = 0)

Count the actions of an interactive object. The function alwys returns the number of the actions regardless of their event types. To count the actions for one event type, please use get_actions and ask for the length of the result list.

Name Type Default Description
Return int   Number of actions
frameRef ItemRef - Valid frame reference. If frameRef is not an interactive object, the functions tries to find this object at first.

0 : Current script frame

Version 4.0.5 R12022, 7. Jul 2016

priint:comet InDesign® Plug-Ins, comet_pdf

static int get_nth_action(
  ItemRef frameRef,
  int index,
  ItemRef outRef = 0)

Get an action of an interactive element by its index.

Name Type Default Description
Return int   0 or ErrorCode @ @param frameRef ItemRef - Valid frame reference. If frameRef is not an interactive object, the functions tries to find this object at first.

0 : Current script frame
index int - Index of action in all actions of the object regardless of their event types
outRef ItemRef 0 Variable for the result

0 : ignore
sonst : allocated ItemRef for the result
#include "internal/types.h"
int main () { ItemRef action = item::alloc (); int a, A;
if (gRun > 1) return 0;
A = interactive::count_actions(gFrame); for (a = 0; a < A; a++) { interactive::get_nth_action (gFrame, a, action); wlog ("", "Action %d : triggered by %d, task %d\n",   a,   interactive::get_event (gFrame, action),   interactive::get_task (gFrame, action)); }
return 0; }

Version 4.0.5 R12022, 7. Jul 2016

priint:comet InDesign® Plug-Ins, comet_pdf

static int add_action(
  ItemRef frameRef,
  int eventType,
  int task,
  ItemRef out_actionRef = 0)

Add an action to an interactive object.

Please note, that actions with targets appear in the action list before actions that do not have targets and they cannot be mixed. Therefor, a new added action must not necessarily be the last in the action list.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid frame reference. If frameRef is not an interactive object, the functions tries to find this object at first.

0 : Current script frame

The function has no effect for state objects (multistates).
eventType int - Event that triggers the action, see here
task int - Task to execute, see here. Use set_task_data to change the parameter of the task.

out_actionRef ItemRef 0 ItemRef for the new created action

0 : ignore
otherwise: llocated ItemRef
#include "internal/types.h"
#include "internal/types.h"
int main () { ItemRef action = item::alloc ();
if (gRun > 1) return 0;
interactive::add_action (gFrame, kMouseUpEvt, kOpenFile, action);
return 0; }

The function creates a "Submit form" actions and then a "Sound" action. In the action list the Sound will appear before the Submit anyway.

#include "internal/types.h"
int main () { ItemRef action = item::alloc ();
if (gRun > 1) return 0;
interactive::add_action (gFrame, kMouseUpEvt, kSubmitForm, action); interactive::add_action (gFrame, kMouseUpEvt, kSound, action);
return 0; }

Version 4.0.5 R11820, 28. Jun 2016

priint:comet InDesign® Plug-Ins, comet_pdf

set_task_data

static int move_action(
  ItemRef frameRef,
  ItemRef actionRef,
  int eventType,
  int newPosition)

Move an action of an interactive object.

Name Type Default Description
Return int   0 or ErrorCode @ @param frameRef ItemRef - Valid frame reference. If frameRef is not an interactive object, the functions tries to find this object at first.

0 : Current script frame
actionRef ItemRef - Valid action of frameRef
eventType int - Destination event type, see here.

0 : leave untouched
newPosition int - New position in actions list of event. If >=0, the action will moved to the end of the list.
#include "internal/types.h"

Make the last "mouse exit" action the first one:

#include "internal/types.h"
int main () { ItemList actions = itemlist::alloc (); ItemRef action = item::alloc ();
if (gRun > 1) return 0;
interactive::get_actions (gFrame, kMouseExitEvt, actions); if (itemlist::length (actions) > 0) { itemlist::get (actions, action, itemlist::length (actions)-1); interactive::move_action(0, action, 0, 0); }
return 0; }

Version 4.0.5 R12022, 12. Jul 2016

priint:comet InDesign® Plug-Ins

static int remove_action(ItemRef frameRef, ItemRef actionRef)

Delete an action of an interactive object.

Name Type Default Description
Return int   0 or ErrorCode @ @param frameRef ItemRef - Valid frame reference. If frameRef is not an interactive object, the functions tries to find this object at first.

0 : Current script frame
actionRef ItemRef - Valid action of frameRef
#include "internal/types.h"

Delete the last mouse exit action.

#include "internal/types.h"
int main () { ItemList actions = itemlist::alloc (); ItemRef action = item::alloc ();
if (gRun > 1) return 0;
interactive::get_actions (gFrame, kMouseExitEvt, actions); if (itemlist::length (actions) > 0) { itemlist::get (actions, action, itemlist::length (actions)-1); interactive::remove_action(0, action); }
return 0; }

Version 4.0.5 R12022, 12. Jul 2016

priint:comet InDesign® Plug-Ins

static int get_event(ItemRef frameRef, ItemRef actionRef)

Event, that triggers an interactice objects action.

Name Type Default Description
Return int   Triggering event for the given action, see table events.
frameRef ItemRef - Valid frame reference. If frameRef is not an interactive object, the functions tries to find this object at first.

0 : Current script frame

The function has no effect for state objects (multistates).
actionRef ItemRef Valid action of interactive object of frameRef.  
#include "internal/types.h"
#include "internal/types.h"
int main () { ItemList actions = itemlist::alloc (); ItemRef action = item::alloc (); int e, i;
if (gRun > 1) return 0;
interactive::get_actions (gFrame, kAnyEvt, actions); wlog ("", "%d actions in object %d\n",   itemlist::length (actions),   item::getint (gFrame));
for (e = kMouseUpEvt; e < kValidateEvt; e++) { interactive::get_actions (gFrame, e, actions); wlog ("", " %d actions of type %d in object %d\n",   itemlist::length (actions),   e,   item::getint (gFrame)); }
interactive::get_actions (gFrame, kAnyEvt, actions); for (i = 0; i < itemlist::length (actions); i++) { itemlist::get (actions, action, i); wlog ("", "Action %d with UID %d is triggered by event %d\n",   i,   item::getint (action),   interactive::get_event (gFrame, action)); }
return 0; }

Version 4.0.5 R11820, 28. Jun 2016

priint:comet InDesign® Plug-Ins, comet_pdf

static int get_task(ItemRef frameRef, ItemRef actionRef)

Get the task executed by an action.

Name Type Default Description
Return int   Task of action, see table Action tasks.
frameRef ItemRef - Valid frame reference. If frameRef is not an interactive object, the functions tries to find this object at first.

0 : Current script frame

The function has no effect for state objects (multistates).
actionRef ItemRef - Valid action of interactive object of frameRef.
#include "internal/types.h"
#include "internal/types.h"
int main () { ItemList actions = itemlist::alloc (); ItemRef action = item::alloc (); int e, i;
if (gRun > 1) return 0;
interactive::get_actions (gFrame, kAnyEvt, actions); wlog ("", "%d actions in object %d\n",   itemlist::length (actions),   item::getint (gFrame));
for (e = kMouseUpEvt; e < kValidateEvt; e++) { interactive::get_actions (gFrame, e, actions); wlog ("", " %d actions of type %d in object %d\n",   itemlist::length (actions),   e,   item::getint (gFrame)); }
interactive::get_actions (gFrame, kAnyEvt, actions); for (i = 0; i < itemlist::length (actions); i++) { itemlist::get (actions, action, i); wlog ("", "Action %d with UID %d is triggered by event %d, task %d\n",   i,   item::getint (action),   interactive::get_event (gFrame, action),   interactive::get_task (gFrame, action)); }
return 0; }

Version 4.0.5 R11820, 28. Jun 2016

priint:comet InDesign® Plug-Ins, comet_pdf

static int get_task_data(
  ItemRef frameRef,
  ItemRef actionRef,
  int* eventType = 0,
  char* eventName = 0,
  int* enabled = 0,
  char* sval1 = 0,
  char* sval2 = 0,
  char* sval3 = 0,
  char* sval4 = 0,
  char* sval5 = 0,
  int* ival1 = 0,
  int* ival2 = 0,
  int* ival3 = 0,
  int* ival4 = 0,
  int* ival5 = 0,
  IDTypeList* lval = 0)

Get the parameter of a task of an action of an interactive object.

The parameters sval1-5, ival1-5 and lval are filled in in dependency of the task performed by the action. Its allowed to set 0 for every variable. The following table describes the event types and their parameters.
Action type Parameter Description
kGoToAnchor (1) : Go to anchor /span[src]{sval1} Complete path of destination file
sval2 Name of anchor
sval3 PDF-Name of anchor
ival1 Zoom
ival2 UID of anchor
kGoToFirstPage (2) : Go to first page ival1 Zoom
kGoToLastPage (3) : Go to last page
kGoToNextPage (4) : Go to next page
kGoToPreviousPage (5) : Go to previous page
kGoToURL (6) : Go to URL sval1 URL
kShowHideFields (7) : Show/Hide buttons lval List of [UID, state] entries

    id1 : UID of push button
    id2 : 0 (hide), 1 (show)
kSound (8) : Audio ival1 Operation

    0 : Play
    1 : Stop
    2 : Pause
    3 : Resume
ival2 Sound-UID
ival3 Volume (0-100)
ival4 Synchronous? (0, 1)
ival5 Repeat? (0, 1)
kMovie (9) : Video ival1 Operation

    0 : Play
    1 : Stop
    2 : Pause
    3 : Resume
ival2 Movie-UID
ival3 NavigationPointID
kAnimation (10) : Animation ival1 Operation<>

    0 : Play
    1 : Stop
    2 : Pause
    3 : Resume
ival2 UID der Animation
ival3 Auto repeat? (0, 1)
kGoToPage (11) : Go to page ival1 1-based page number
ival2 Zoom
kSwitchToMSOState (12) : Go to state
kSwitchToNextMSOState (13) : Go to next state
kSwitchToPrevMSOState (14) : Go to previous state
ival1 UID of state
ival2 0-based index in state
ival3 switchToPriorStateOnRollOff (0, 1)
ival4 loopAtBeginningOrEnd (0, 1)
kGoToNextView (15) : Go to next view
kGoToPreviousView (16) : Go to previous view
no parameters
kOpenFile (17) : Open file sval1 Complete path to file
kViewZoom (18) : Zoom view ival1 Zoom
kPrintForm (19) : Print form No additional information necessary, not supported by CS5.5
kSubmitForm (20) : Submit form sval1 Ziel-URLto send, not supported by CS5.5
kResetForm (21) : Clear form No additional information necessary
kExecJavascript (22) : Execute JavaScript See here
The following table shows all available zoom states.
ID Name
0 Full screen
0 Current zoom
1 Actual size
2 Fit in window
3 Fit width
4 Fit visible

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid frame reference. If frameRef is not an interactive object, the functions tries to find this object at first.

0 : Current script frame

The function has no effect for state objects (multistates).
actionRef ItemRef - Valid action of interactive object of frameRef.
eventType int* 0 Triggering event of task

0 : ignore
eventName String/char* 0 Name of task

0 : Name
enabled int* 0 Task enabled?

0 : nein
1 : yes
sval1-5 String/char* 0 see above
ival1-5 int* 0 see above
lval IDTypeList 0 see above
#include "internal/types.h"
#include "internal/types.h"
int main () { ItemList actions = itemlist::alloc (); ItemRef action = item::alloc (); int i, etype, eenabled; char ename [512], sval1 [512];
if (gRun > 1) return 0;
interactive::get_actions (gFrame, kMouseUpEvt, actions); for (i = 0; i < itemlist::length (actions); i++) { itemlist::get (actions, action, i); if (interactive::get_task (gFrame, action) == kSubmitForm) { interactive::get_task_data (gFrame, action, &etype, ename, &eenabled, sval1); wlog ("", "Submit '%s' (%d, '%s', %d)\n", sval1, etype, ename, eenabled); } }
return 0; }

Version 4.0.5 R11820, 28. Jun 2016

priint:comet InDesign® Plug-Ins, comet_pdf

get_actions

static int set_task_data(
  ItemRef frameRef,
  ItemRef actionRef,
  ...)

Change the properties of an formield task.

The function may chenge the current document selection.

Take care to use the task dependent function parameters! To get an actions task you may use get_task. The following table lists the function parameters in dependence of the actions task:
Task Parameter Description
kGoToAnchor (1) : Go to anchor String/char* Complete path of destination file
int UID of anchor
int Zoom
kGoToFirstPage (2) : Go to first page int Zoom
kGoToLastPage (3) : Go to last page
kGoToNextPage (4) : Go to next page
kGoToPreviousPage (5) : Go to previous page
kGoToURL (6) : Go to URL String/char* URL of the destination page
kShowHideFields (7) : Show/hide buttons IDTypeList List of button UIDs and their visibility

    id1 : UID of the button
    id2 : 0 (invisible), 1 (visible), 2 (Leave unchanged)
kSound (8) : Audio int Operation

    0 : Play
    1 : Stop
    2 : Pause
    3 : Rewind
int Sound-UID
int Lautstärke (0-100)
int Synchron? (0, 1)
int Automatisch wiederholen? (0, 1)
kMovie (9) : Video int Operation

    0 : Play
    1 : Stop
    2 : Pause
    3 : Rewind
int Movie-UID
int NavigationPointID
kAnimation (10) : Animation int Operation

    0 : Play
    1 : Stop
    2 : Pause
    3 : Rewind
int UID of animation
int Repeat automatically? (0, 1)
kGoToPage (11) : Go to page int 1-basierte Page number
int Zoom
kSwitchToMSOState (12) : Go to status
kSwitchToNextMSOState (13) : Go to next status
kSwitchToPrevMSOState (14) : Go to previous status
int UID of status
int 0-based index of the status
int switchToPriorStateOnRollOff (0, 1)
int loopAtBeginningOrEnd (0, 1)
kGoToNextView (15) : Go to next view
kGoToPreviousView (16) : Go to previous view
no further parameters
kOpenFile (17) : Open file String/char* Full path of the file
kViewZoom (18) : View zoom int Zoom
kPrintForm (19) : Print form no further parameters
kSubmitForm (20) : Send form String/char* Target URL for sending the form
kResetForm (21) : Reset form no further parameters
kExecJavascript (22) : Execute JavaScript String/char* Javascript source code. You can find more information here.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid frame reference. If frameRef is not an interactive object, the functions tries to find this object at first.

0 : Current script frame

The function has no effect for state objects (multistates).
actionRef ItemRef - Valid action of interactive object of frameRef.
... ... - Task specific parameters. See above table.
#include "internal/types.h"

#include "internal/types.h"
int main () { ItemRef action = item::alloc (); int result;
if (gRun > 1) return 0;
result = interactive::add_action (gFrame, kMouseUpEvt, kSubmitForm, action); wlog ("", "add action : %d\n", result);
result = interactive::set_task_data (gFrame, action, "ftp://www.sawadee.th/hallo.pdf"); wlog ("", "set_task_data : %d\n", result);
return 0; }

Creating a Javascript action. When the button is clicked, the currently selected item of the popup menu (Combobox) C3 is displayed. The line separators in the display text are encoded with \013 here.

#include "internal/types.h"
int main ()
{
    ItemRef		fr			= item::alloc ();
    ItemRef		action		= item::alloc ();
    char 	*	js			= "var field = this.getField('C3');\
    var selectedIndex = field.currentValueIndices;\
    var exportValue = field.getItemAt(selectedIndex);\
    var displayValue = field.getItemAt(selectedIndex, false);\
    app.alert ('Index : ' + selectedIndex + '\\013Exportvalue : \"' + exportValue + '\"\\013DisplayValue : ' + displayValue + '\"');\
    ";
item::define (fr, 0, 221); interactive::add_action (fr, kMouseUpEvt, kExecJavascript, action); interactive::set_task_data (fr, action, js);
return 0; }

Version 4.0.5 R11820, 28. Jun 2016

priint:comet InDesign® Plug-Ins

Preconditions
#include "internal/types.h"

Author
Paul Seidel
Version
12.03.2024, 15:56 Uhr
Since
Version 4.0.5 R11820, 24. Jun 2016
See Also
frame
item

Alphabetic index HTML hierarchy of classes or Java