Struct egui::containers::ComboBox [−][src]
pub struct ComboBox { /* fields omitted */ }
Expand description
A drop-down selection menu with a descriptive label.
egui::ComboBox::from_label( "Select one!")
.selected_text(format!("{:?}", selected))
.show_ui(ui, |ui| {
ui.selectable_value(&mut selected, Enum::First, "First");
ui.selectable_value(&mut selected, Enum::Second, "Second");
ui.selectable_value(&mut selected, Enum::Third, "Third");
}
);
Implementations
Label shown next to the combo box
Without label.
What we show as the currently selected value
Show the combo box, with the given ui code for the menu contents.
Returns InnerResponse { inner: None }
if the combo box is closed.
Show a list of items with the given selected index.
let alternatives = ["a", "b", "c", "d"];
let mut selected = 2;
egui::ComboBox::from_label( "Select one!").show_index(
ui,
&mut selected,
alternatives.len(),
|i| alternatives[i].to_owned()
);