Dialogs
Cross-platform native file dialog implementation.
This class provides access to native file dialogs for opening files, selecting directories, and saving files. It supports:
- Desktop platforms (Mac/Windows/Linux): Uses native OS dialogs via linc_dialogs
- Electron: Uses Electron's dialog API for web-based desktop apps
- Other platforms: Falls back to warning logs (no dialog support)
The dialogs are synchronous on desktop but appear asynchronous due to the callback-based API. This ensures consistent behavior across platforms.
File filters can be specified to limit selectable file types, improving user experience by showing only relevant files.
Static Members
Opens a native file selection dialog.
Shows the platform's standard file picker dialog, allowing the user to browse and select a single file. The dialog can be configured with file type filters to show only specific file extensions.
On Electron, this also ensures keyboard state is reset after the dialog closes to prevent stuck keys.
Name | Type | Default | Description |
---|---|---|---|
title |
String | The dialog window title | |
filters |
Array<DialogsFileFilter> | (optional) | Optional array of file type filters |
done |
Function | Callback invoked with the selected file path (null if cancelled) |
Opens a native directory selection dialog.
Shows the platform's standard folder picker dialog, allowing the user to browse and select a directory. On supported platforms, this can also create new directories during selection.
Platform capabilities:
- Desktop: Full directory browsing and creation
- Electron: Directory selection with create option
- Others: Not supported (logs warning)
Name | Type | Description |
---|---|---|
title |
String | The dialog window title |
done |
Function | Callback invoked with the selected directory path (null if cancelled) |
Opens a native save file dialog.
Shows the platform's standard save dialog, allowing the user to specify a location and filename for saving. Features include:
- Overwrite confirmation for existing files
- File type filters to suggest appropriate extensions
- Directory creation during navigation
The dialog doesn't actually save any data - it only returns the chosen file path for the application to use.
Name | Type | Default | Description |
---|---|---|---|
title |
String | The dialog window title | |
filters |
Array<DialogsFileFilter> | (optional) | Optional array of file type filters (first filter used as default on some platforms) |
done |
Function | Callback invoked with the chosen file path (null if cancelled) |