Skip to main content

Module opaque

Module opaque 

Source
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 Opaque::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")),
    ]
}

Structs§

Opaque
Wraps the given widget and captures any mouse button presses inside the bounds of the widget—effectively making it opaque.