Skip to main content

ModalRequest

Struct ModalRequest 

Source
pub struct ModalRequest {
    pub content: ModalContent,
    pub presentation: ModalPresentation,
    pub close_behavior: ModalCloseBehavior,
    pub title: Option<String>,
    pub size: Option<(u32, u32)>,
    pub focus_target: Option<WidgetId>,
    pub on_dismiss: Option<OverlayDismissCallback>,
}
Expand description

A framework-level request to present a modal.

Fields§

§content: ModalContent§presentation: ModalPresentation§close_behavior: ModalCloseBehavior§title: Option<String>§size: Option<(u32, u32)>§focus_target: Option<WidgetId>

Optional explicit initial-focus target inside the modal content subtree. When None, the framework falls back to first_focusable_descendant(content_id). When Some, the id is consulted first and the framework focuses it if the widget exists and is still active in the target tree; otherwise it falls back to first_focusable_descendant. Required for MessageBox-style alerts where the default button may not be the first focusable descendant in tree-walk order.

§on_dismiss: Option<OverlayDismissCallback>

Invoked when the modal is dismissed by any path (Escape, close button, click-outside, explicit ctx.dismiss_modal()). Only fired for in-tree presentations — native-window modals do not have a reliable dismiss callback yet.

Implementations§

Source§

impl ModalRequest

Source

pub fn in_tree(content_id: WidgetId) -> Self

Present an existing widget subtree as modal content.

Source

pub fn deferred( builder: impl FnOnce(&mut WidgetTree) -> WidgetId + 'static, ) -> Self

Build modal content on demand in the presentation target tree.

Source

pub fn presentation(self, presentation: ModalPresentation) -> Self

Source

pub fn close_behavior(self, close_behavior: ModalCloseBehavior) -> Self

Source

pub fn title(self, title: impl Into<String>) -> Self

Source

pub fn size(self, width: u32, height: u32) -> Self

Source

pub fn on_dismiss(self, callback: OverlayDismissCallback) -> Self

Register a callback invoked when the modal is dismissed by any path (Escape, close button, click-outside, explicit ctx.dismiss_modal()). Only fired for in-tree presentations.

Source

pub fn focus_target(self, id: WidgetId) -> Self

Direct initial focus to a specific widget inside the modal content subtree. The id must resolve to a widget that exists and is active at the time the modal is presented; if it does not, the framework falls back to first_focusable_descendant(content_id).

Trait Implementations§

Source§

impl Debug for ModalRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.