Function egui::containers::popup::popup_above_or_below_widget
source · pub fn popup_above_or_below_widget<R>(
parent_ui: &Ui,
popup_id: Id,
widget_response: &Response,
above_or_below: AboveOrBelow,
close_behavior: PopupCloseBehavior,
add_contents: impl FnOnce(&mut Ui) -> R,
) -> Option<R>
Expand description
Shows a popup above or below another widget.
Useful for drop-down menus (combo boxes) or suggestion menus under text fields.
The opened popup will have a minimum width matching its parent.
You must open the popup with crate::Memory::open_popup
or crate::Memory::toggle_popup
.
Returns None
if the popup is not open.
let response = ui.button("Open popup");
let popup_id = ui.make_persistent_id("my_unique_id");
if response.clicked() {
ui.memory_mut(|mem| mem.toggle_popup(popup_id));
}
let below = egui::AboveOrBelow::Below;
let close_on_click_outside = egui::popup::PopupCloseBehavior::CloseOnClickOutside;
egui::popup::popup_above_or_below_widget(ui, popup_id, &response, below, close_on_click_outside, |ui| {
ui.set_min_width(200.0); // if you want to control the size
ui.label("Some more info, or things you can select:");
ui.label("…");
});