pub struct Popover { /* private fields */ }Expand description
A surface anchored to a trigger, holding whatever the caller puts in it.
Open state and the element that had the keyboard before opening both
outlive a frame, so a popover is a view rather than a builder. The body is
a callback instead of a stored element because an AnyElement can be
consumed once, while an open popover re-renders for as long as it stays
open.
Implementations§
Source§impl Popover
impl Popover
pub fn new( ident: impl Into<Ident>, _window: &mut Window, cx: &mut Context<'_, Self>, ) -> Self
Sourcepub fn trigger(self, label: impl Into<SharedString>) -> Self
pub fn trigger(self, label: impl Into<SharedString>) -> Self
The label of the control that opens the surface.
pub fn trigger_icon(self, icon: Icon) -> Self
Sourcepub fn content(
self,
content: impl Fn(&mut Window, &mut App) -> AnyElement + 'static,
) -> Self
pub fn content( self, content: impl Fn(&mut Window, &mut App) -> AnyElement + 'static, ) -> Self
Supplies the body, rebuilt on every frame the popover is open.
pub fn placement(self, placement: Placement) -> Self
Sourcepub fn dismissable(self, dismissable: bool) -> Self
pub fn dismissable(self, dismissable: bool) -> Self
Whether escape and a click outside close the surface. A popover that is not dismissable installs neither handler.
pub fn is_open(&self) -> bool
pub fn is_dismissable(&self) -> bool
pub fn open(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
Sourcepub fn close(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
pub fn close(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
Closes the surface and gives the keyboard back to the trigger.
pub fn toggle(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
Trait Implementations§
impl EventEmitter<PopoverEvent> for Popover
Source§impl Focusable for Popover
impl Focusable for Popover
Source§fn focus_handle(&self, _cx: &App) -> FocusHandle
fn focus_handle(&self, _cx: &App) -> FocusHandle
Returns the focus handle associated with this view.
Auto Trait Implementations§
impl !RefUnwindSafe for Popover
impl !Send for Popover
impl !Sync for Popover
impl !UnwindSafe for Popover
impl Freeze for Popover
impl Unpin for Popover
impl UnsafeUnpin for Popover
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
Converts
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> ⓘ
Converts
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