IDesktopMessageBoxes interface

Namespace Runic.Platform in Runic.Platform 0.23.0

public interface IDesktopMessageBoxes

Native message boxes owned by one window.

Remarks

IWindowPlatformServices.MessageBoxes of a window, which a ViewModel can also take directly. Its capability is PlatformCapabilityIds.MessageBoxes. Methods are safe to call from any thread; the box is shown on the window's thread.

Methods

ShowAsync

ValueTask<PlatformResult<DesktopMessageBoxButton?>> ShowAsync(DesktopMessageBox messageBox, CancellationToken cancellationToken = default)

Shows a message box modal to the window and returns the button the user chose.

Parameters

messageBox

The box; see DesktopMessageBox for its rules.

cancellationToken

Closes the box, which then throws OperationCanceledException.

Returns

Success with the chosen button, one of DesktopMessageBox.Buttons, or with null when the box had no buttons of the application or GTK closed it without a button, such as when the user pressed Esc in a box without a cancel button. Unavailable: PlatformUnavailableReason.OwnerUnavailable before the window opens or on a host without a native owner, PlatformUnavailableReason.OwnerClosed once it closed, also while the box is shown, and PlatformUnavailableReason.BackendUnavailable when the platform cannot show the box, such as GTK before 4.10.

Exceptions

ArgumentException

messageBox breaks a rule.

ArgumentNullException

messageBox is null.

OperationCanceledException

cancellationToken was cancelled.