app.execDialog method's dialog box validate, commit, and ItemID handlers do not behave as documented
I am trying to create a dialog box for use in a Dynamic Stamp and the app.execDialog method's dialog box validate, commit, and ItemID handlers do not behave as documented.
I am using Adobe Acrobat Pro Continuous Release Version 2024.004.20272 (24.4.20272.0) and am following the guidelines in the Adobe JavaScript APIs reference, https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#execdialog
The initialize handler is called when the dialog box is being initialized, and the destroy handler is called when the Cancel button is clicked, as expected, however, the validate, commit, and ItemID handlers do not work as described.
For example:
- The validate handler is not called when a field is modified, though it does get called when the Ok button is clicked.
- The commit and ok handlers are not called when the Ok button is clicked.
- The ItemID handler is not called when the edit_text boxes lose focus.
- The only way to close the dialog box is to click the Cancel button, but I expected the Ok button to also exit the dialog box.
- Finally, the API reference does not specify an ok handler, however, Example 2 in the reference shows an ok handler, which also does not work.
Here is my test procedure and the results:
- Open the JavaScript console.
- Copy and paste the script into the console.
- Press <CTRL>-A to select all and press <CTRL>-<ENTER> to execute the script.
- "Initializing!" is printed to the console, as expected.
- Type some text into the fname edit_text box.
- Press <TAB> to change the focus to the lname edit_text box.
- Nothing is printed to the console. I expected to see "Modifying ItemID!"
- Type some text into the lnam edit_text box.
- Press <TAB> to change the focus to the Ok button.
- Nothing is printed to the console. I expected to see "Modifying ItemID!"
- Press <ENTER> to click the OK button.
- "Validating!" is printed to the console. I expected to see "Commiting!" and possibly "OKing!"
- Press <ENTER> to click the OK button again .
- "Validating!" is printded to the console. I expected to see "Commiting!" and possibly "OKing!"
- Use the mouse to click the OK button again.
- "Validating!" is printed to the console. I expected to see "Commiting!" and possibly "OKing!"
- Press <TAB> to change the focus to the Cancel button.
- Nothing is printed to the console. I expected to see "Modifying ItemID!"
- Press <ENTER> to click the Cancel button.
- "Destroying!" is printed to the console, and the diolog window is closed, then "cancel" and "true" are also printed to the console, as expected.
Here is my script which demonstrates the issues:
var dialog1 = {
initialize: function(dialog)
{
// Called when the dialog box is being initialized.
console.println("Initializing!");
},
validate: function(dialog)
{
// Called when a field is modified to determine if the value is
// acceptable (returning true) or unacceptable (returning false).
console.println("Validating!");
},
commit: function(dialog)
{
// Called when the OK button of dialog box is clicked.
console.println("Committing!");
},
ok: function(dialog)
{
// Called after commit when the OK button of dialog box is clicked.
console.println("OKing!");
},
destroy: function(dialog)
{
// Called when the dialog box is being destroyed.
console.println("Destroying!");
},
ItemID: function(dialog)
{
// Called when the dialog box element ItemID is modified.
// For a text box, it is when the text box loses focus.
console.println("Modifying ItemID!");
},
description:
{
type: "cluster",
name: "Main Dialog",
align_children: "align_left",
item_id: "main",
first_tab: "fnam",
elements: [
{
type: "view",
align_children: "align_row",
elements: [
{
type: "static_text",
name: "First Name: "
},
{
item_id: "fnam",
next_tab: "lnam",
type: "edit_text",
alignment: "align_fill",
width: 300,
height: 20
}
]
},
{
type: "view",
align_children: "align_row",
elements: [
{
type: "static_text",
name: "Last Name: "
},
{
item_id: "lnam",
next_tab: "ok",
type: "edit_text",
alignment: "align_fill",
width: 300,
height: 20
}
]
},
{
item_id: "ok",
next_tab: "fnam",
type: "ok_cancel",
alignment: "align_right",
ok_name: "Ok",
cancel_name: "Cancel"
}
]
}
};
console.println(app.execDialog(dialog1));
I am new to Adobe JavaScript programming. I was able to create a dynamic stamp using the app.response() and the app.popUpMenuEx() methods, however, the stamp requires 10 user inputs so now I am trying to use the app.execDialog() method to consolidate all the user input into a single dialog. Any insight would be greatly appreciated.
