Skip to content

Dialog API ​

Provides native system dialogs for opening files, saving files, selecting folders, and modal confirmations.

dialog ​

dialog.confirm ​

Show a modal task dialog with custom buttons. Escape and the close button do not dismiss it.

ParameterTypeRequiredDescription
titlestringNoWindow title. Defaults to "Confirm", localized to the UI language.
messagestringNoBody text. Default: "".
type"info" | "warning" | "error" | "question"NoIcon. The task dialog shows question with the information icon. Default: "question".
buttonsstring[]NoButton labels, in order. Defaults to OK and Cancel, localized to the UI language.
defaultButtonintegerNoIndex of the initially focused button. Default: 0.

Returns

FieldTypeDescription
responseintegerZero-based index of the clicked button in buttons. -1 only when not even the fallback message box could be shown.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const res = await fb2k.invoke('dialog.confirm', {
	title: 'Remove Track',
	message: 'Remove this track from the playlist?',
});
if (res.success === false) throw new Error(res.error);
const { response } = res;

dialog.openFile ​

Show the system dialog for opening files.

ParameterTypeRequiredDescription
titlestringNoWindow title. Defaults to "Open File", localized to the UI language.
multiplebooleanNoAllow selecting several files. Default: false.
defaultPathstringNoFolder the dialog opens in, every time it is shown. %music% expands to the Music folder. Ignored when the path does not resolve to a folder. Default: "".
filtersFileFilter[]NoFile type list. When omitted or empty, the dialog shows a single "All Files" entry.
filters[].namestringNoLabel shown in the file type list. Defaults to "Files", localized to the UI language.
filters[].extensionsstring[]NoExtensions without the leading dot, such as flac; * matches every file.

Returns

FieldTypeDescription
canceledbooleantrue when the user closed the dialog without choosing.
filePathsstring[]Chosen files; empty when canceled.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const res = await fb2k.invoke('dialog.openFile', {
	title: 'Add Audio Files',
	multiple: true,
	filters: [{ name: 'Audio', extensions: ['flac', 'mp3', 'm4a'] }],
});
if (res.success === false) throw new Error(res.error);
const { canceled, filePaths } = res;

dialog.openFolder ​

Show the system dialog for choosing a folder.

ParameterTypeRequiredDescription
titlestringNoWindow title. Defaults to "Select Folder", localized to the UI language.
defaultPathstringNoFolder the dialog opens in, every time it is shown. %music% expands to the Music folder. Ignored when the path does not resolve to a folder. Default: "".

Returns

FieldTypeDescription
canceledbooleantrue when the user closed the dialog without choosing.
folderPathstringChosen folder, which need not be defaultPath; empty when canceled.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const res = await fb2k.invoke('dialog.openFolder', {
	title: 'Choose Music Folder',
	defaultPath: 'D:\\Music',
});
if (res.success === false) throw new Error(res.error);
const { canceled, folderPath } = res;

dialog.saveFile ​

Show the system dialog for saving a file.

ParameterTypeRequiredDescription
titlestringNoWindow title. Defaults to "Save File", localized to the UI language.
defaultNamestringNoFile name filled in when the dialog opens. Default: "".
filtersFileFilter[]NoFile type list. When omitted or empty, the dialog shows a single "All Files" entry.
filters[].namestringNoLabel shown in the file type list. Defaults to "Files", localized to the UI language.
filters[].extensionsstring[]NoExtensions without the leading dot, such as flac; * matches every file.

Returns

FieldTypeDescription
canceledbooleantrue when the user closed the dialog without choosing.
filePathstringChosen file; empty when canceled. The system asks before an existing file is overwritten.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const res = await fb2k.invoke('dialog.saveFile', {
	defaultName: 'export.m3u8',
	filters: [{ name: 'Playlist', extensions: ['m3u8'] }],
});
if (res.success === false) throw new Error(res.error);
const { canceled, filePath } = res;

Dialog boundaries ​

  • Native dialog cancellation returns canceled: true with an empty result path/list. Dialog initialization failures add error and set canceled: false.