Using Dialogs
In this chapter, we're going to learn how to use dialogs.
File Dialogs
You can use Open Dialog and Save Dialog to allow users to choose files or directories.
Following is an example of Open Dialog for choosing a text *.txt file.
var filters = [
{ name: "Text Files", extensions: [ "txt" ] }
]
var selected = app.dialogs.showOpenDialog("Select a text file...", null, filters)
// Returns an array of paths of selected filesFollowing is an example of Save Dialog for getting a file name.
var filters = [
{ name: "Text Files", extensions: [ "txt" ] }
]
var selected = app.dialogs.showSaveDialog("Save text as...", null, filters)
// Returns a file path to saveMessage Dialogs
There are three types of message dialogs to show error, alert, and info.
Input Dialogs
Here are code examples to show dialogs to get user inputs.
Input Dialog (single line text)
Text Dialog (multi line text)
Confirm Dialog
Select Radio Dialog
Select Dropdown Dialog
Color Dialog
Font Dialog
Element Dialogs
If you need to ask users to pick an model element, Element Picker Dialog can be used as follow:

Or, you may need to constrain a list of elements which can be selected by users. Then you can use Element List Picker Dialog.

Toast
Toast is a way to show a short message in some seconds. It appears on the top of diagram area and disappears automatically after some seconds.
Last updated