pub struct ToastState { /* private fields */ }Expand description
One retained notification. Applications own its message, actions and stacking.
Showing a toast never takes focus. Its countdown starts when mounted and pauses while hovered, while it or a descendant owns focus, and while the window is inactive. Resuming spends only the remaining duration. Explicitly dismissing a focused toast restores the focus captured when it was shown; closing an unfocused toast never moves another control’s focus.
Implementations§
Source§impl ToastState
impl ToastState
Sourcepub fn new(window: &mut Window, cx: &mut Context<'_, Self>) -> Self
pub fn new(window: &mut Window, cx: &mut Context<'_, Self>) -> Self
Uses a five-second lifetime; configure it before mounting with
Self::with_duration. Keep the matching Toast mounted even when closed.
Sourcepub fn with_duration(self, duration: Duration) -> Self
pub fn with_duration(self, duration: Duration) -> Self
A nonzero amount of active, unattended time before dismissal.
pub fn is_open(&self) -> bool
Sourcepub fn focus_handle(&self) -> &FocusHandle
pub fn focus_handle(&self) -> &FocusHandle
The non-Tab-stop notification scope. Its action buttons keep their own ordinary Tab stops; applications may use this handle to announce/focus the notification on an explicit user request.
Sourcepub fn show(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
pub fn show(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
Shows or replaces the notification and restarts its full lifetime.
pub fn dismiss(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
Trait Implementations§
impl EventEmitter<ToastEvent> for ToastState
Auto Trait Implementations§
impl !RefUnwindSafe for ToastState
impl !Send for ToastState
impl !Sync for ToastState
impl !UnwindSafe for ToastState
impl Forget for ToastState
impl Freeze for ToastState
impl Move for ToastState
impl Unpin for ToastState
impl UnsafeUnpin for ToastState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more