These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Custom Dialog Boxes and Syntax/Possibilities

Nifty
Registered: Jan 16 2011
Posts: 17
Answered

Losing a lot of sleep over this.
 
I am trying to create a dialogue box that allows the user to enter some search text and then enter some of the advanced search function choices ,either by dropdown choice or by checkboxes, rather like the built in advanced search. Once all the selections have been made a large button labelled SEARCH will then be pressed which will initiate the search of a specific catalogue index
 
Creating the dialogue box using AcroDialog has been easy.
Getting the various functions within the dialogue to work is proving considerably harder. A lot of the code found in the form examples I've found don't want to work within the confines of a dialog box.
 
I have two fundamental issues/questions.
 
Firstly,is it possible and if so how, to take a text value entered into a text edit box and use that in another dialogue element before running the commit function.
 
Secondly, is it possible to create javascript that will close down (cancel) the dialogue from a normal button.
I do not wish to use an OK_Cancel button arrangement because I wish to use a single OK button, enlarged and renamed to SEARCH to execute the end product of the dialogue box.
 
I hope that all makes sense and someone may be able to answer my questions.
 
Many thanks,
 
Nifty Styles
 
Using Acrobat 8.2.5 Professional
(Norfolk, England)

My Product Information:
Acrobat Pro 8.1.7, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Accepted Answer
There are a couple of issues with code in a dialog. First, any code that runs inside a dialog is running inside the dialog object, so the meaning of "this" changes. In a dialog the "this" keyword is a pointer to the dialog object, not to the document object. If you want to use the document object, it has to be accessed from a local or global variable that was set before the dialog was activated. Second, dialogs are modal, which means that all keyboard and mouse activity is locked onto the dialog while it is running. This modal context gets in the way of certain JavaScript operations, such as timers. However, most document operations are still doable, including the display of both the standard alert boxes and custom dialogs.

When the dialog is running, values are acquired from dialog with the "dialog.store()" function. This is the function that is used in the "Commit" function to store data when the dialog is closed. See that function for an example.

The dialog can be close with the "dialog.end()" function. This function has a single input, which is a string that is returned by the "app.execDialog()" function. Calling this function does cause the dialog to call the commit or validate functions.


Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Nifty
Registered: Jan 16 2011
Posts: 17
Thom,

Thank you very much for your reply and all your help with this project.

When I have a minute I intend to post up some of the issues I had and the answers because I have found this forum of invaluable use but one or two of my answers haven't come up through a search on here.
If I post up how I have solved the problems then it is there for the prosperity of others.

I have had one issue that I didn't resolve but circumnavigated.
I wanted to use a Case Switch operation to set one variable based on the return value of a dropdown list.
I have been unable to get the Case switch to work but have used an if else sub to reach the same end (though less tidily I think).

Would my problem be that the return value from the dropdown is a string containing multiple words, eg "Select all users") and the Case operation will only work on a single text word, eg. case "Allusers": ~etc., rather than case "Select all users": ~etc. ?

I'll post this as a seperate thread so that it comes up readily for future searches.

Once again thank you for your invaluable knowledge and assistance.

Nifty.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Even if a string contains multiple words, its still a single string of characters. There is no problem with a it being used in a case statement. I suspect the issue might be with a type conversion. The list functions used by AcroDialogs return an array of strings. Do an explicit conversion to string before using the return value.

For example:
switch(myDropVar.toString())
{
case "Select all users":
}



Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script