Dialog
This part of the runtime provides access to native dialogs, such as File Selectors and Message boxes.
Dialog is currently unsupported in the JS runtime.
OpenDirectoryDialog
Opens a dialog that prompts the user to select a directory. Can be customised using OpenDialogOptions.
Go: OpenDirectoryDialog(ctx context.Context, dialogOptions OpenDialogOptions) (string, error)
Returns: Selected directory (blank if the user cancelled) or an error
OpenFileDialog
Opens a dialog that prompts the user to select a file. Can be customised using OpenDialogOptions.
Go: OpenFileDialog(ctx context.Context, dialogOptions OpenDialogOptions) (string, error)
Returns: Selected file (blank if the user cancelled) or an error
OpenMultipleFilesDialog
Opens a dialog that prompts the user to select multiple files. Can be customised using OpenDialogOptions.
Go: OpenMultipleFilesDialog(ctx context.Context, dialogOptions OpenDialogOptions) ([]string, error)
Returns: Selected files (nil if the user cancelled) or an error
SaveFileDialog
Opens a dialog that prompts the user to select a filename for the purposes of saving. Can be customised using SaveDialogOptions.
Go: SaveFileDialog(ctx context.Context, dialogOptions SaveDialogOptions) (string, error)
Returns: The selected file (blank if the user cancelled) or an error
MessageDialog
Displays a message using a message dialog. Can be customised using MessageDialogOptions.
Go: MessageDialog(ctx context.Context, dialogOptions MessageDialogOptions) (string, error)
Returns: The text of the selected button or an error
Options
OpenDialogOptions
type OpenDialogOptions struct {
DefaultDirectory string
DefaultFilename string
Title string
Filters []FileFilter
ShowHiddenFiles bool
CanCreateDirectories bool
ResolvesAliases bool
TreatPackagesAsDirectories bool
}
| Field | Description | Win | Mac | Lin |
|---|---|---|---|---|
| DefaultDirectory | The directory the dialog will show when opened | ✅ | ✅ | ✅ |
| DefaultFilename | The default filename | ✅ | ✅ | ✅ |
| Title | Title for the dialog | ✅ | ✅ | ✅ |
| Filters | A list of file filters | ✅ | ✅ | ✅ |
| ShowHiddenFiles | Show files hidden by the system | ✅ | ✅ | |
| CanCreateDirectories | Allow user to create directories | ✅ | ||
| ResolvesAliases | If true, returns the file not the alias | ✅ | ||
| TreatPackagesAsDirectories | Allow navigating into packages | ✅ |
SaveDialogOptions
type SaveDialogOptions struct {
DefaultDirectory string
DefaultFilename string
Title string
Filters []FileFilter
ShowHiddenFiles bool
CanCreateDirectories bool
TreatPackagesAsDirectories bool
}
| Field | Description | Win | Mac | Lin |
|---|---|---|---|---|
| DefaultDirectory | The directory the dialog will show when opened | ✅ | ✅ | ✅ |
| DefaultFilename | The default filename | ✅ | ✅ | ✅ |
| Title | Title for the dialog | ✅ | ✅ | ✅ |
| Filters | A list of file filters | ✅ | ✅ | ✅ |
| ShowHiddenFiles | Show files hidden by the system | ✅ | ✅ | |
| CanCreateDirectories | Allow user to create directories | ✅ | ||
| TreatPackagesAsDirectories | Allow navigating into packages | ✅ |
MessageDialogOptions
type MessageDialogOptions struct {
Type DialogType
Title string
Message string
Buttons []string
DefaultButton string
CancelButton string
}
| Field | Description | Win | Mac | Lin |
|---|---|---|---|---|
| Type | The type of message dialog, eg question, info... | ✅ | ✅ | ✅ |
| Title | Title for the dialog | ✅ | ✅ | ✅ |
| Message | The message to show the user | ✅ | ✅ | ✅ |
| Buttons | A list of button titles | ✅ | ||
| DefaultButton | The button with this text should be treated as default. Bound to return. | ✅* | ✅ | |
| CancelButton | The button with this text should be treated as cancel. Bound to escape | ✅ |