Struct Popover
pub struct Popover<W, V, Message> { /* private fields */ }Expand description
A floating piece of content that appears over another element.
The popover does not control its own visibility. Instead, the popover
argument is an Option: Some displays the overlay (open), and None
hides it (closed). The base is always present.
When the user clicks outside of the popover’s bounds, the popover notifies
the application through its on_close handler.
The popover() helper wraps the popup in opaque(), so mouse button
presses inside the popup’s bounds are captured and do not pass through to
the elements below. Use Self::passthrough to let them fall through to
the base layer, and Self::capture_scroll to also capture scroll wheel
events over the popup.
§Example
use iced::widget::{button, container, popover, text};
#[derive(Clone)]
enum Message {
Close,
}
fn view(state: &State) -> impl Widget<Message> {
// The base is always present. The `popover` argument is `Some` when the
// popover is open and `None` when it is closed.
popover(
button(text("Click me!")).on_press(Message::Close),
state.is_open.then(|| {
container(text("This is the popover contents!")).padding(10)
}),
)
.position(popover::Position::Bottom)
.on_close(Message::Close)
}Implementations§
§impl<W, V, Message> Popover<W, V, Message>
impl<W, V, Message> Popover<W, V, Message>
pub fn new(content: W, popup: Option<V>) -> Popover<W, V, Message>
pub fn new(content: W, popup: Option<V>) -> Popover<W, V, Message>
Creates a new Popover.
It expects:
- the
contentwidget that the popover is anchored to (the base), and - the optional
popupwidget to display:Somewhen the popover is open andNonewhen it is closed.
The base is always present; it is the popup argument that controls
whether the overlay is displayed. By default, the Popover is
positioned Position::Auto; use the Self::position method to set
a specific position.
pub fn on_close(self, message: Message) -> Popover<W, V, Message>
pub fn on_close(self, message: Message) -> Popover<W, V, Message>
Sets the message that will be produced when the user clicks outside of
the Popover’s bounds.
This is typically how the application decides to close the popover, by
setting the popover argument to None.
pub fn position(self, position: Position) -> Popover<W, V, Message>
pub fn position(self, position: Position) -> Popover<W, V, Message>
Sets the Position of the Popover.
By default, the Popover is positioned Position::Auto, which
places it on the side of the base with the most available space.
pub fn gap(self, gap: impl Into<Pixels>) -> Popover<W, V, Message>
pub fn gap(self, gap: impl Into<Pixels>) -> Popover<W, V, Message>
Sets the gap between the content and its Popover.
pub fn snap_within_viewport(self, snap: bool) -> Popover<W, V, Message>
pub fn snap_within_viewport(self, snap: bool) -> Popover<W, V, Message>
Sets whether the Popover is snapped within the viewport.
§impl<W, V, Message> Popover<W, Opaque<V>, Message>
impl<W, V, Message> Popover<W, Opaque<V>, Message>
pub fn passthrough(self) -> Popover<W, V, Message>
pub fn passthrough(self) -> Popover<W, V, Message>
Makes interactions on the popup of the Popover fall through
to the base layer.
pub fn capture_scroll(self, capture: bool) -> Popover<W, Opaque<V>, Message>
pub fn capture_scroll(self, capture: bool) -> Popover<W, Opaque<V>, Message>
Sets whether the scroll wheel should be captured when the cursor is over the bounds of the popup.
By default, only mouse button presses are captured. Enabling this flag also captures scroll wheel events, preventing them from passing through to the elements below.
Trait Implementations§
§impl<W, V, Message, Theme, Renderer> Widget<Message, Theme, Renderer> for Popover<W, V, Message>
impl<W, V, Message, Theme, Renderer> Widget<Message, Theme, Renderer> for Popover<W, V, Message>
§fn update(
&mut self,
tree: &mut Tree,
event: &Event,
layout: Layout,
cursor: Cursor,
renderer: &Renderer,
shell: &mut Shell<'_, Message>,
viewport: &Rectangle,
)
fn update( &mut self, tree: &mut Tree, event: &Event, layout: Layout, cursor: Cursor, renderer: &Renderer, shell: &mut Shell<'_, Message>, viewport: &Rectangle, )
§fn draw(
&self,
tree: &Tree,
renderer: &mut Renderer,
theme: &Theme,
style: &Style,
layout: Layout,
cursor: Cursor,
viewport: &Rectangle,
)
fn draw( &self, tree: &Tree, renderer: &mut Renderer, theme: &Theme, style: &Style, layout: Layout, cursor: Cursor, viewport: &Rectangle, )
Widget using the associated Renderer.§fn mouse_interaction(
&self,
tree: &Tree,
layout: Layout,
cursor: Cursor,
viewport: &Rectangle,
renderer: &Renderer,
) -> Interaction
fn mouse_interaction( &self, tree: &Tree, layout: Layout, cursor: Cursor, viewport: &Rectangle, renderer: &Renderer, ) -> Interaction
§fn operate(
&mut self,
tree: &mut Tree,
layout: Layout,
viewport: &Rectangle,
renderer: &Renderer,
operation: &mut dyn Operation,
)
fn operate( &mut self, tree: &mut Tree, layout: Layout, viewport: &Rectangle, renderer: &Renderer, operation: &mut dyn Operation, )
§fn overlay<'b>(
&'b mut self,
tree: &'b mut Tree,
layout: Layout,
renderer: &Renderer,
viewport: &Rectangle,
translation: Vector,
window: Size,
) -> Vec<Element<'b, Message, Theme, Renderer>>
fn overlay<'b>( &'b mut self, tree: &'b mut Tree, layout: Layout, renderer: &Renderer, viewport: &Rectangle, translation: Vector, window: Size, ) -> Vec<Element<'b, Message, Theme, Renderer>>
Widget.Auto Trait Implementations§
impl<W, V, Message> Freeze for Popover<W, V, Message>
impl<W, V, Message> RefUnwindSafe for Popover<W, V, Message>
impl<W, V, Message> Send for Popover<W, V, Message>
impl<W, V, Message> Sync for Popover<W, V, Message>
impl<W, V, Message> Unpin for Popover<W, V, Message>
impl<W, V, Message> UnsafeUnpin for Popover<W, V, Message>
impl<W, V, Message> UnwindSafe for Popover<W, V, Message>
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
Source§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Application.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