mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 13:50:04 -04:00
Add new ComboBox builder to replace the combo_box_with_label function
This commit is contained in:
@@ -65,11 +65,13 @@ impl super::View for FontBook {
|
||||
|
||||
ui.separator();
|
||||
|
||||
egui::combo_box_with_label(ui, "Text style", format!("{:?}", self.text_style), |ui| {
|
||||
for style in egui::TextStyle::all() {
|
||||
ui.selectable_value(&mut self.text_style, style, format!("{:?}", style));
|
||||
}
|
||||
});
|
||||
egui::ComboBox::from_label("Text style")
|
||||
.selected_text(format!("{:?}", self.text_style))
|
||||
.show_ui(ui, |ui| {
|
||||
for style in egui::TextStyle::all() {
|
||||
ui.selectable_value(&mut self.text_style, style, format!("{:?}", style));
|
||||
}
|
||||
});
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Show:");
|
||||
|
||||
@@ -136,11 +136,14 @@ impl WidgetGallery {
|
||||
ui.end_row();
|
||||
|
||||
ui.add(doc_link_label("Combo box", "combo_box"));
|
||||
egui::combo_box_with_label(ui, "Take your pick", format!("{:?}", radio), |ui| {
|
||||
ui.selectable_value(radio, Enum::First, "First");
|
||||
ui.selectable_value(radio, Enum::Second, "Second");
|
||||
ui.selectable_value(radio, Enum::Third, "Third");
|
||||
});
|
||||
|
||||
egui::ComboBox::from_label("Take your pick")
|
||||
.selected_text(format!("{:?}", radio))
|
||||
.show_ui(ui, |ui| {
|
||||
ui.selectable_value(radio, Enum::First, "First");
|
||||
ui.selectable_value(radio, Enum::Second, "Second");
|
||||
ui.selectable_value(radio, Enum::Third, "Third");
|
||||
});
|
||||
ui.end_row();
|
||||
|
||||
ui.add(doc_link_label("Slider", "Slider"));
|
||||
|
||||
@@ -87,11 +87,13 @@ impl Widgets {
|
||||
ui.radio_value(&mut self.radio, Enum::Third, "Third");
|
||||
});
|
||||
|
||||
egui::combo_box_with_label(ui, "Combo Box", format!("{:?}", self.radio), |ui| {
|
||||
ui.selectable_value(&mut self.radio, Enum::First, "First");
|
||||
ui.selectable_value(&mut self.radio, Enum::Second, "Second");
|
||||
ui.selectable_value(&mut self.radio, Enum::Third, "Third");
|
||||
});
|
||||
egui::ComboBox::from_label("Combo Box")
|
||||
.selected_text(format!("{:?}", self.radio))
|
||||
.show_ui(ui, |ui| {
|
||||
ui.selectable_value(&mut self.radio, Enum::First, "First");
|
||||
ui.selectable_value(&mut self.radio, Enum::Second, "Second");
|
||||
ui.selectable_value(&mut self.radio, Enum::Third, "Third");
|
||||
});
|
||||
});
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
|
||||
Reference in New Issue
Block a user