For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/lynxtron/api/@lynx-js/lynxtron/Interface.Dialog.md.
  • English
  • @lynx-js/lynxtron / Dialog

    Dialog

    Methods

    showErrorBox()

    showErrorBox(title: string, content: string): void

    Displays a modal dialog that shows an error message.

    This API can be called safely before the ready event the app module emits, it is usually used to report errors in early stage of startup. If called before the app readyevent on Linux, the message will be emitted to stderr, and no GUI dialog will appear.

    Parameters

    ParameterType
    titlestring
    contentstring

    Returns

    void

    Defined in

    apis/api/dialog.d.ts:396


    showMessageBox()

    window: BaseWindow

    showMessageBox(window: BaseWindow, options: MessageBoxOptions): Promise<MessageBoxReturnValue>

    resolves with a promise containing the following properties:

    • response number - The index of the clicked button.
    • checkboxChecked boolean - The checked state of the checkbox if checkboxLabel was set. Otherwise false.

    Shows a message box.

    The window argument allows the dialog to attach itself to a parent window, making it modal.

    Parameters

    ParameterType
    windowBaseWindow
    optionsMessageBoxOptions

    Returns

    Promise<MessageBoxReturnValue>

    Defined in

    apis/api/dialog.d.ts:409

    options: MessageBoxOptions

    showMessageBox(options: MessageBoxOptions): Promise<MessageBoxReturnValue>

    resolves with a promise containing the following properties:

    • response number - The index of the clicked button.
    • checkboxChecked boolean - The checked state of the checkbox if checkboxLabel was set. Otherwise false.

    Shows a message box.

    The window argument allows the dialog to attach itself to a parent window, making it modal.

    Parameters

    ParameterType
    optionsMessageBoxOptions

    Returns

    Promise<MessageBoxReturnValue>

    Defined in

    apis/api/dialog.d.ts:425


    showMessageBoxSync()

    window: BaseWindow

    showMessageBoxSync(window: BaseWindow, options: MessageBoxSyncOptions): number

    the index of the clicked button.

    Shows a message box, it will block the process until the message box is closed. It returns the index of the clicked button.

    The window argument allows the dialog to attach itself to a parent window, making it modal. If window is not shown dialog will not be attached to it. In such case it will be displayed as an independent window.

    Parameters

    ParameterType
    windowBaseWindow
    optionsMessageBoxSyncOptions

    Returns

    number

    Defined in

    apis/api/dialog.d.ts:436

    options: MessageBoxSyncOptions

    showMessageBoxSync(options: MessageBoxSyncOptions): number

    the index of the clicked button.

    Shows a message box, it will block the process until the message box is closed. It returns the index of the clicked button.

    The window argument allows the dialog to attach itself to a parent window, making it modal. If window is not shown dialog will not be attached to it. In such case it will be displayed as an independent window.

    Parameters

    ParameterType
    optionsMessageBoxSyncOptions

    Returns

    number

    Defined in

    apis/api/dialog.d.ts:450


    showOpenDialog()

    window: BaseWindow

    showOpenDialog(window: BaseWindow, options: OpenDialogOptions): Promise<OpenDialogReturnValue>

    Resolve with an object containing the following:

    • canceled boolean - whether or not the dialog was canceled.
    • filePaths string[] - An array of file paths chosen by the user. If the dialog is cancelled this will be an empty array.
    • bookmarks string[] (optional) macOS mas - An array matching the filePaths array of base64 encoded strings which contains security scoped bookmark data. securityScopedBookmarks must be enabled for this to be populated. (For return values, see table here.)

    The window argument allows the dialog to attach itself to a parent window, making it modal.

    The filters specifies an array of file types that can be displayed or selected when you want to limit the user to a specific type. For example:

    The extensions array should contain extensions without wildcards or dots (e.g. 'png' is good but '.png' and '*.png' are bad). To show all files, use the '*' wildcard (no other wildcard is supported).

    NOTE

    On Windows and Linux an open dialog can not be both a file selector and a directory selector, so if you set properties to ['openFile', 'openDirectory'] on these platforms, a directory selector will be shown.

    NOTE

    On Linux defaultPath is not supported when using portal file chooser dialogs unless the portal backend is version 4 or higher. You can use --xdg-portal-required-version command-line switch to force gtk or kde dialogs.

    Parameters

    ParameterType
    windowBaseWindow
    optionsOpenDialogOptions

    Returns

    Promise<OpenDialogReturnValue>

    Defined in

    apis/api/dialog.d.ts:480

    options: OpenDialogOptions

    showOpenDialog(options: OpenDialogOptions): Promise<OpenDialogReturnValue>

    Resolve with an object containing the following:

    • canceled boolean - whether or not the dialog was canceled.
    • filePaths string[] - An array of file paths chosen by the user. If the dialog is cancelled this will be an empty array.
    • bookmarks string[] (optional) macOS mas - An array matching the filePaths array of base64 encoded strings which contains security scoped bookmark data. securityScopedBookmarks must be enabled for this to be populated. (For return values, see table here.)

    The window argument allows the dialog to attach itself to a parent window, making it modal.

    The filters specifies an array of file types that can be displayed or selected when you want to limit the user to a specific type. For example:

    The extensions array should contain extensions without wildcards or dots (e.g. 'png' is good but '.png' and '*.png' are bad). To show all files, use the '*' wildcard (no other wildcard is supported).

    NOTE

    On Windows and Linux an open dialog can not be both a file selector and a directory selector, so if you set properties to ['openFile', 'openDirectory'] on these platforms, a directory selector will be shown.

    NOTE

    On Linux defaultPath is not supported when using portal file chooser dialogs unless the portal backend is version 4 or higher. You can use --xdg-portal-required-version command-line switch to force gtk or kde dialogs.

    Parameters

    ParameterType
    optionsOpenDialogOptions

    Returns

    Promise<OpenDialogReturnValue>

    Defined in

    apis/api/dialog.d.ts:513


    showOpenDialogSync()

    window: BaseWindow

    showOpenDialogSync(window: BaseWindow, options: OpenDialogSyncOptions): undefined | string[]

    the file paths chosen by the user; if the dialog is cancelled it returns undefined.

    The window argument allows the dialog to attach itself to a parent window, making it modal.

    The filters specifies an array of file types that can be displayed or selected when you want to limit the user to a specific type. For example:

    The extensions array should contain extensions without wildcards or dots (e.g. 'png' is good but '.png' and '*.png' are bad). To show all files, use the '*' wildcard (no other wildcard is supported).

    NOTE

    On Windows and Linux an open dialog can not be both a file selector and a directory selector, so if you set properties to ['openFile', 'openDirectory'] on these platforms, a directory selector will be shown.

    NOTE

    On Linux defaultPath is not supported when using portal file chooser dialogs unless the portal backend is version 4 or higher. You can use --xdg-portal-required-version command-line switch to force gtk or kde dialogs.

    Parameters

    ParameterType
    windowBaseWindow
    optionsOpenDialogSyncOptions

    Returns

    undefined | string[]

    Defined in

    apis/api/dialog.d.ts:536

    options: OpenDialogSyncOptions

    showOpenDialogSync(options: OpenDialogSyncOptions): undefined | string[]

    the file paths chosen by the user; if the dialog is cancelled it returns undefined.

    The window argument allows the dialog to attach itself to a parent window, making it modal.

    The filters specifies an array of file types that can be displayed or selected when you want to limit the user to a specific type. For example:

    The extensions array should contain extensions without wildcards or dots (e.g. 'png' is good but '.png' and '*.png' are bad). To show all files, use the '*' wildcard (no other wildcard is supported).

    NOTE

    On Windows and Linux an open dialog can not be both a file selector and a directory selector, so if you set properties to ['openFile', 'openDirectory'] on these platforms, a directory selector will be shown.

    NOTE

    On Linux defaultPath is not supported when using portal file chooser dialogs unless the portal backend is version 4 or higher. You can use --xdg-portal-required-version command-line switch to force gtk or kde dialogs.

    Parameters

    ParameterType
    optionsOpenDialogSyncOptions

    Returns

    undefined | string[]

    Defined in

    apis/api/dialog.d.ts:562


    showSaveDialog()

    window: BaseWindow

    showSaveDialog(window: BaseWindow, options: SaveDialogOptions): Promise<SaveDialogReturnValue>

    Resolve with an object containing the following:

    • canceled boolean - whether or not the dialog was canceled.
    • filePath string - If the dialog is canceled, this will be an empty string.
    • bookmark string (optional) macOS mas - Base64 encoded string which contains the security scoped bookmark data for the saved file. securityScopedBookmarks must be enabled for this to be present. (For return values, see table here.)

    The window argument allows the dialog to attach itself to a parent window, making it modal.

    The filters specifies an array of file types that can be displayed, see dialog.showOpenDialog for an example.

    NOTE

    On macOS, using the asynchronous version is recommended to avoid issues when expanding and collapsing the dialog.

    Parameters

    ParameterType
    windowBaseWindow
    optionsSaveDialogOptions

    Returns

    Promise<SaveDialogReturnValue>

    Defined in

    apis/api/dialog.d.ts:582

    options: SaveDialogOptions

    showSaveDialog(options: SaveDialogOptions): Promise<SaveDialogReturnValue>

    Resolve with an object containing the following:

    • canceled boolean - whether or not the dialog was canceled.
    • filePath string - If the dialog is canceled, this will be an empty string.
    • bookmark string (optional) macOS mas - Base64 encoded string which contains the security scoped bookmark data for the saved file. securityScopedBookmarks must be enabled for this to be present. (For return values, see table here.)

    The window argument allows the dialog to attach itself to a parent window, making it modal.

    The filters specifies an array of file types that can be displayed, see dialog.showOpenDialog for an example.

    NOTE

    On macOS, using the asynchronous version is recommended to avoid issues when expanding and collapsing the dialog.

    Parameters

    ParameterType
    optionsSaveDialogOptions

    Returns

    Promise<SaveDialogReturnValue>

    Defined in

    apis/api/dialog.d.ts:605


    showSaveDialogSync()

    window: BaseWindow

    showSaveDialogSync(window: BaseWindow, options: SaveDialogSyncOptions): string

    the path of the file chosen by the user; if the dialog is cancelled it returns an empty string.

    The window argument allows the dialog to attach itself to a parent window, making it modal.

    The filters specifies an array of file types that can be displayed, see dialog.showOpenDialog for an example.

    Parameters

    ParameterType
    windowBaseWindow
    optionsSaveDialogSyncOptions

    Returns

    string

    Defined in

    apis/api/dialog.d.ts:616

    options: SaveDialogSyncOptions

    showSaveDialogSync(options: SaveDialogSyncOptions): string

    the path of the file chosen by the user; if the dialog is cancelled it returns an empty string.

    The window argument allows the dialog to attach itself to a parent window, making it modal.

    The filters specifies an array of file types that can be displayed, see dialog.showOpenDialog for an example.

    Parameters

    ParameterType
    optionsSaveDialogSyncOptions

    Returns

    string

    Defined in

    apis/api/dialog.d.ts:630

    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.