The Dialog object allows you to display dialogs that prompt the user for confirmation, allow them to input text strings or passwords, and select checkbox options or choose from a drop-down list. You can also use this object to display a popup menu on screen.
You can create a Dialog object from the DOpus.Dlg, Lister.Dlg, Tab.Dlg, Func.Dlg and Command.Dlg methods.
See the Example Scripts section for an example of its use.
There are two different ways to use the Dialog object. You can either:
The one-shot methods accept several parameters but are generally not as flexible as building up the dialog and then calling Show.
Property Name |
Return Type |
Description |
---|---|---|
buttons |
string |
Specifies the buttons that are displayed at the bottom of the dialog. These buttons are used to close the dialog. The Show method returns a value indicating which button was chosen (and this value is also available in the result property). Multiple button strings must be separated with vertical bar characters (|). If a button has more than one button then by definition the last one is the "cancel" button. For example: dlg.buttons =
"OK|Retry|Cancel" dlg.buttons =
"&OK|&Retry|&Cancel" dlg.buttons =
"OK|Retry+Retry All|Cancel" dlg.buttons =
"OK|Retry+Retry All=Retry All|Skip+Skip if same modified time=Skip Same
Time|Cancel" |
choices |
object:Vector(string) |
This property uses either a Vector or an array of strings to provide a list of multiple options that can be shown to the user. The list can be presented in one of three ways:
|
confirm |
bool |
In a text entry dialog (i.e. the max property has been specified) setting confirm to True will require that the user types the entered text again (in a second text field) to confirm it (e.g. for a password). |
defvalue |
string |
In a text entry dialog (i.e. the max property has been specified) this property allows you to initialize the text field with a default value. (Old scripts may use "default" instead of "defvalue"; this is deprecated because it does not work in JScript where "default" is a reserved keyword.) |
defid |
int |
Allows you to change the default button (i.e. the action that will occur if the user hits enter) in the dialog. Normally the first button is the default - this has a defid of 1. The second button would have a defid of 2, and so on. If a dialog has more than one button then by definition the very last button is the "cancel" button, and this has a defid of 0. |
icon |
string |
Displays one of several standard icons in the top-left corner of the dialog, which can be used, for example, to indicate the severity of an error condition. The valid values for this property are warning, error, info and question. |
input |
string |
In a text entry dialog, this property returns the text string that the user entered (i.e. once the Show method has returned). |
list |
object:Vector(bool) |
In conjunction with the choices property, this will
cause the choices to be presented as a checkbox list. You can initialize
this Vector or array with the same number of items as the
choices property, and set each one to True or
False to control the default state of each checkbox. Or,
simply set this value to 0 to activate the checkbox list
without having to initialize the state of each checkbox. |
max |
int |
This property enables text entry in the dialog - a text field will be
displayed allowing the user to enter a string. Set this property to the
maximum length of the string you want the user to be able to enter (or
0 to have no limit). |
menu |
object:Vector(int) |
In conjunction with the choices property, this will cause the choices to be presented as a popup menu rather than in a dialog. The menu will be displayed at the current mouse coordinates. You can initialize this Vector or array with the same number of items as the choices property, and set each one to a value representing various flags that control the appearance of the menu item. The available flags are as follows - their values must be added together if you need to specify more than one flag per item. 1 - bold (indicates the default
item) You can also simply set this value to 0 or 1 to activate the popup menu without having to provide flags for each item (if set to 1, the top item in the menu will appear bolded).
|
message |
string |
Specifies the message text displayed in the dialog. |
options |
collection:DialogOption |
This is a collection of five options that will be displayed as
checkboxes in the dialog. Unlike the choices /
list scrolling checkbox list, these options are displayed
as physical checkbox controls. By default the five checkboxes are
uninitialized and won't be displayed, but if you assign a label to any of
them they will be shown to the user. When the Show method returns you can obtain the state of the checkboxes using the state property of each DialogOption object. |
password |
bool |
In a text entry dialog, set this property to True to make the text entry field a password field. In a password field the characters the user enters are not displayed. |
result |
int |
This property returns the index of the button chosen by the user to
close the dialog. The left-most button is index 1, the
next button is index 2, and so on. If a dialog has more
than one button then by definition the last (right-most) button is the
"cancel" button and so this will return index
0. |
select |
bool |
In a text entry dialog, set this property to True to automatically select the contents of the input field (as specified by the default property) when the dialog opens. |
selection |
int |
In a drop-down list dialog (one with the choices property set without either list or menu), this property returns the index of the item chosen from the drop-down list after the Show method returns. |
sort |
bool |
Set this property to True if the list of choices given by the choices property should be sorted alphabetically. |
title |
string |
Specifies the title text of the dialog. |
window |
Use this to specify the parent window of the dialog. The dialog will
appear centered over the top of the specified window. You can provide
either a Listeror a Tab object. If
you are showing this dialog in response to the OnAboutScript event, you can also
pass the value of the AboutData.window property. |
Method Name |
Arguments |
Return Type |
Description |
---|---|---|---|
Folder |
<string:title> |
object:Path |
Displays a "Browse for Folder" dialog letting the user select a folder. The optional parameters are: title - specify title of the dialog A Path object is returned to indicate the folder chosen by the user. This object will have an additional result property that will be False if the user cancelled the dialog - the other normal Path properties will only be valid if result is True. |
GetString |
<string:message> |
string |
Displays a text entry dialog allowing the user to enter a string. The optional parameters are: message - specify message string in the
dialog |
Multi |
<string:title> |
collection:Item |
Displays a "Browse to Open File" dialog that lets the user select one or more files. The optional parameters are: title - specify title of the dialog A collection of Item objects is
returned to indicate the files selected by the user. The returned object
will have a result property that you should check first -
the collection of items is only valid if result returns
True. If it returns False it means the
user cancelled the dialog. |
Open |
<string:title> |
object:Item |
Displays a "Browse to Open File" dialog that lets the user select a single file. The optional parameters are: title - specify title of the dialog |
Request |
<string:message> |
int |
Displays a dialog with one or more buttons. The optional parameters are: message - specify message string in the
dialog |
Show |
none |
int |
Displays the dialog that has been pre-configured using the various
properties of this object. See the properties section above for a full
description of these. The return value is the index of the button selected by the user, and this is also available in the result property once the method returns. The left-most button is index 1, the next button is index 2, and so on. If a dialog has more than one button then by definition the last (right-most) button is the "cancel" button and so this will return index 0. |
Save |
<string:title> |
object:Path |
Displays a "Browse to Save File" dialog that lets the user select a single file or enter a new filename to save. The optional parameters are: title - specify title of the dialog |