Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
portals::ui::MessageBox Class Reference

Copyable UI-affine observation of a reusable choice dialog. Copies retain no scene/widget/callback. Cold handles return CLOSED; original removed identities return STALE_NODE. A request remains busy through deferred callback admission or async retirement. More...

#include <message_box.hpp>

Inheritance diagram for portals::ui::MessageBox:
portals::ui::MessageBoxportals::ui::MessageBox portals::ui::Ref< MessageBox >

Public Member Functions

 MessageBox ()
 Create an unpublished observing slot; allocation can throw.
template<class Callback>
requires portals::detail::ManagedAction<Callback, MessageResult>
DialogCommandResult open (Callback callback, std::source_location origin=std::source_location::current()) const
template<class T, class Callback>
requires std::derived_from<T, Widget> && portals::detail::ManagedAction<Callback, MessageResult>
DialogCommandResult open (const Ref< T > &owner, Callback callback, std::source_location origin=std::source_location::current()) const
DialogCommandResult cancel (std::source_location origin=std::source_location::current()) const
std::expected< std::shared_ptr< const MessageResult >, ManagedError > lastResult () const
std::expected< AsyncReceive< MessageResult >, ManagedError > receive (const UiAsyncContext &context) const
template<class T>
requires std::derived_from<T, Widget>
std::expected< AsyncReceive< MessageResult >, ManagedError > receive (const UiAsyncContext &context, const Ref< T > &owner) const

Friends

struct detail::MessageAccess

Detailed Description

Copyable UI-affine observation of a reusable choice dialog. Copies retain no scene/widget/callback. Cold handles return CLOSED; original removed identities return STALE_NODE. A request remains busy through deferred callback admission or async retirement.

Member Function Documentation

◆ cancel()

DialogCommandResult portals::ui::MessageBox::cancel ( std::source_location origin = std::source_location::current()) const
Parameters
originCommand site.
Returns
Checked CANCEL dismissal; a closed panel is an equal no-op. Explicit cleanup of a surviving failed-open panel preserves its already latched error.

◆ lastResult()

std::expected< std::shared_ptr< const MessageResult >, ManagedError > portals::ui::MessageBox::lastResult ( ) const
Returns
Owning immutable snapshot, WOULD_BLOCK before latch, or exact facade liveness/affinity failure. Once latched, task cancellation and transport pressure never replace its pointer or value.

◆ open() [1/2]

template<class Callback>
requires portals::detail::ManagedAction<Callback, MessageResult>
DialogCommandResult portals::ui::MessageBox::open ( Callback callback,
std::source_location origin = std::source_location::current() ) const
inline
Template Parameters
CallbackExisting compact managed action accepting const MessageResult& or no arguments.
Parameters
callbackOwning captures admitted once on a later Scheduler DATA dispatch.
originPublic command site retained by diagnostics.
Returns
Checked admission; no callback is entered for a rejected request. Default owner is scene.root().

◆ open() [2/2]

template<class T, class Callback>
requires std::derived_from<T, Widget> && portals::detail::ManagedAction<Callback, MessageResult>
DialogCommandResult portals::ui::MessageBox::open ( const Ref< T > & owner,
Callback callback,
std::source_location origin = std::source_location::current() ) const
inline
Template Parameters
TExplicit owner widget type.
CallbackExisting compact managed action.
Parameters
ownerLive ordinary-body or active-modal owner in the same scene.
callbackOwning deferred action; the argument is borrowed only during admission.
originPublic command site.
Returns
Checked admission, preserving old result on failure.

◆ receive() [1/2]

std::expected< AsyncReceive< MessageResult >, ManagedError > portals::ui::MessageBox::receive ( const UiAsyncContext & context) const
Parameters
contextSame-scene existing UiAsync context.
Returns
Owning reservation; opens only at actual await. The ordinary AsyncReceive outer error retains transport errors; its MessageResult retains full domain errors. Reservations, copied awaiters and their final release stay on the constructing UI thread.

◆ receive() [2/2]

template<class T>
requires std::derived_from<T, Widget>
std::expected< AsyncReceive< MessageResult >, ManagedError > portals::ui::MessageBox::receive ( const UiAsyncContext & context,
const Ref< T > & owner ) const
inline
Template Parameters
TExplicit owner type.
Parameters
contextSame-scene receiver.
ownerIndependent live owner.
Returns
Checked owning reservation; owner removal can deliver a full error to an independent receiver.

The documentation for this class was generated from the following file: