OpenFileOptions record

Namespace Runic.Platform in Runic.Platform 0.23.0

public sealed record OpenFileOptions : IEquatable<OpenFileOptions>

Inherits or implements IEquatable.

Options for selecting existing files.

Parameters

OwnerPolicy

The required dialog ownership; OwnerPolicy.PreferOwner shows an unowned dialog for a presentation without a native owner.

Constructors

OpenFileOptions

public OpenFileOptions(OwnerPolicy OwnerPolicy = OwnerPolicy.RequireOwner)

Options for selecting existing files.

Parameters

OwnerPolicy

The required dialog ownership; OwnerPolicy.PreferOwner shows an unowned dialog for a presentation without a native owner.

Properties

Filters

public ImmutableArray<FileDialogFilter> Filters { get; init; }

The file types the dialog offers, the first selected initially; empty offers every file.

Exceptions

ArgumentException

The array contains null.

Remarks

Filters are hints that Runic does not enforce on the selection; see FileDialogFilter.

InitialDirectory

public string? InitialDirectory { get; init; }

The fully qualified directory the dialog opens in, or null for the platform's choice.

Exceptions

ArgumentException

The path is not fully qualified or contains NUL.

Remarks

A directory that does not exist is ignored by the platform. The xdg-desktop-portal FileChooser before version 4 ignores it when opening files.

OwnerPolicy

public OwnerPolicy OwnerPolicy { get; init; }

The required dialog ownership; OwnerPolicy.PreferOwner shows an unowned dialog for a presentation without a native owner.

ShowFilterChoice

public bool ShowFilterChoice { get; init; }

Whether macOS adds a pop-up to the panel for choosing one of OpenFileOptions.Filters; false by default.

Remarks

Without it a macOS panel offers the files of every filter at once and reports no Selected.SelectedFilter. With it, the panel shows the first filter's files and the pop-up switches between filters. Windows and Linux always show their own filter choice and ignore this value.

Title

public string? Title { get; init; }

The dialog's title, such as "Import backup", or null for the platform's own, such as "Open".

Exceptions

ArgumentException

The title contains NUL.

Remarks

Windows shows it in the dialog's title bar and the xdg-desktop-portal FileChooser and GTK 3 in the dialog's header. A macOS panel has no visible title, so it shows the text as the panel's message above the files.