Struct Opaque
pub struct Opaque<W> { /* private fields */ }Expand description
Wraps the given widget and captures any mouse button presses inside the bounds of the widget—effectively making it opaque.
This widget is meant to be used to mark elements in a Stack, or inside an
overlay—like the popup of a Popover—to avoid mouse events from passing
through to the elements below.
By default, only mouse button presses are captured. Use
Self::capture_scroll to also capture scroll wheel events, so that
scrolling does not pass through to the elements below.
§Example
use iced::widget::{button, opaque, stack, text};
#[derive(Clone)]
enum Message {
ButtonPressed,
}
fn view(state: &State) -> impl Widget<Message> {
stack![
// This button lies below the opaque top layer: mouse events over
// the top layer do not pass through to it.
button("Click me!").on_press(Message::ButtonPressed),
opaque(text("I am opaque")),
]
}Implementations§
§impl<W> Opaque<W>
impl<W> Opaque<W>
pub fn capture_scroll(self, capture: bool) -> Opaque<W>
pub fn capture_scroll(self, capture: bool) -> Opaque<W>
Sets whether the scroll wheel should be captured when the cursor is
over the bounds of the Opaque.
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.
pub fn into_inner(self) -> W
pub fn into_inner(self) -> W
Returns the wrapped content.
Trait Implementations§
§impl<'a, W, Message, Theme, Renderer> From<Opaque<W>> for Element<'a, Message, Theme, Renderer>where
Message: 'a,
Theme: 'a,
Renderer: 'a,
W: Widget<Message, Theme, Renderer> + 'a,
impl<'a, W, Message, Theme, Renderer> From<Opaque<W>> for Element<'a, Message, Theme, Renderer>where
Message: 'a,
Theme: 'a,
Renderer: 'a,
W: Widget<Message, Theme, Renderer> + 'a,
§impl<W, Message, Theme, Renderer> Widget<Message, Theme, Renderer> for Opaque<W>where
W: Widget<Message, Theme, Renderer>,
impl<W, Message, Theme, Renderer> Widget<Message, Theme, Renderer> for Opaque<W>where
W: Widget<Message, Theme, Renderer>,
§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 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 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 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 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> Freeze for Opaque<W>where
W: Freeze,
impl<W> RefUnwindSafe for Opaque<W>where
W: RefUnwindSafe,
impl<W> Send for Opaque<W>where
W: Send,
impl<W> Sync for Opaque<W>where
W: Sync,
impl<W> Unpin for Opaque<W>where
W: Unpin,
impl<W> UnsafeUnpin for Opaque<W>where
W: UnsafeUnpin,
impl<W> UnwindSafe for Opaque<W>where
W: UnwindSafe,
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