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
impl ModalRequest
Sourcepub fn in_tree(content_id: WidgetId) -> Self
pub fn in_tree(content_id: WidgetId) -> Self
Present an existing widget subtree as modal content.
Sourcepub fn deferred(
builder: impl FnOnce(&mut WidgetTree) -> WidgetId + 'static,
) -> Self
pub fn deferred( builder: impl FnOnce(&mut WidgetTree) -> WidgetId + 'static, ) -> Self
Build modal content on demand in the presentation target tree.
pub fn presentation(self, presentation: ModalPresentation) -> Self
pub fn close_behavior(self, close_behavior: ModalCloseBehavior) -> Self
pub fn title(self, title: impl Into<String>) -> Self
pub fn size(self, width: u32, height: u32) -> Self
Sourcepub fn on_dismiss(self, callback: OverlayDismissCallback) -> Self
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.
Sourcepub fn focus_target(self, id: WidgetId) -> Self
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).