Struct egui_bind::Bind

source ·
pub struct Bind<'a, B: BindTarget> { /* private fields */ }
Expand description

Widget for showing the bind itself

Implementations§

Creates a new bind widget

Examples found in repository?
src/lib.rs (line 125)
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
pub fn show_bind_popup(
    ui: &mut Ui,
    bind: &mut impl BindTarget,
    popup_id_source: impl Hash,
    widget_response: &Response,
) {
    let popup_id = Id::new(popup_id_source);

    if widget_response.secondary_clicked() {
        ui.memory().toggle_popup(popup_id);
    }

    let mut should_close = false;
    let was_opened = ui.memory().is_popup_open(popup_id);

    let mut styles = ui.ctx().style().as_ref().clone();
    let saved_margin = styles.spacing.window_margin;

    styles.spacing.window_margin = Margin::same(0.);
    ui.ctx().set_style(styles.clone());

    egui::popup_below_widget(ui, popup_id, widget_response, |ui| {
        let r = ui.add(Bind::new(popup_id.with("_bind"), bind));

        if r.changed() || ui.input().key_down(Key::Escape) {
            ui.memory().close_popup();
            should_close = true;
        }
    });
    styles.spacing.window_margin = saved_margin;
    ui.ctx().set_style(styles);

    if !should_close && was_opened {
        ui.memory().open_popup(popup_id);
    }
}

Trait Implementations§

Allocate space, interact, paint, and return a Response. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.