From 3cd3cceefd8141242d2ac4fae918bc0ac2eaf6c9 Mon Sep 17 00:00:00 2001 From: Alan Race Date: Fri, 4 Feb 2022 14:11:08 +0100 Subject: [PATCH] Add method to enable generation of a ComboBox with both id and label (#1204) --- egui/src/containers/combo_box.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/egui/src/containers/combo_box.rs b/egui/src/containers/combo_box.rs index adab23b3..8ec4d7aa 100644 --- a/egui/src/containers/combo_box.rs +++ b/egui/src/containers/combo_box.rs @@ -27,6 +27,16 @@ pub struct ComboBox { } impl ComboBox { + /// Create new `ComboBox` with id and label + pub fn new(id_source: impl std::hash::Hash, label: impl Into) -> Self { + Self { + id_source: Id::new(id_source), + label: Some(label.into()), + selected_text: Default::default(), + width: None, + } + } + /// Label shown next to the combo box pub fn from_label(label: impl Into) -> Self { let label = label.into();