summaryrefslogtreecommitdiffstats
path: root/widget/src/helpers.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2023-07-26 22:45:56 +0200
committerLibravatar GitHub <noreply@github.com>2023-07-26 22:45:56 +0200
commita0a3cf7eb71ca9a934a60144b92c555cf7efe69a (patch)
tree3657e6311e60e3fdbf530f1117be7e42d2cf6b16 /widget/src/helpers.rs
parent4cf1b4fd1c8f45fe50ff254decd91f0d589f70ff (diff)
parent559ebdbb3a0b90ff28f361f5466f17178b6d8137 (diff)
downloadiced-a0a3cf7eb71ca9a934a60144b92c555cf7efe69a.tar.gz
iced-a0a3cf7eb71ca9a934a60144b92c555cf7efe69a.tar.bz2
iced-a0a3cf7eb71ca9a934a60144b92c555cf7efe69a.zip
Merge pull request #1954 from jhff/widget/combobox
Add `ComboBox` widget
Diffstat (limited to 'widget/src/helpers.rs')
-rw-r--r--widget/src/helpers.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/widget/src/helpers.rs b/widget/src/helpers.rs
index 3f5136f8..9c3c83a9 100644
--- a/widget/src/helpers.rs
+++ b/widget/src/helpers.rs
@@ -1,6 +1,7 @@
//! Helper functions to create pure widgets.
use crate::button::{self, Button};
use crate::checkbox::{self, Checkbox};
+use crate::combo_box::{self, ComboBox};
use crate::container::{self, Container};
use crate::core;
use crate::core::widget::operation;
@@ -252,6 +253,23 @@ where
PickList::new(options, selected, on_selected)
}
+/// Creates a new [`ComboBox`].
+///
+/// [`ComboBox`]: widget::ComboBox
+pub fn combo_box<'a, T, Message, Renderer>(
+ state: &'a combo_box::State<T>,
+ placeholder: &str,
+ selection: Option<&T>,
+ on_selected: impl Fn(T) -> Message + 'static,
+) -> ComboBox<'a, T, Message, Renderer>
+where
+ T: std::fmt::Display + Clone,
+ Renderer: core::text::Renderer,
+ Renderer::Theme: text_input::StyleSheet + overlay::menu::StyleSheet,
+{
+ ComboBox::new(state, placeholder, selection, on_selected)
+}
+
/// Creates a new horizontal [`Space`] with the given [`Length`].
///
/// [`Space`]: widget::Space