diff options
author | 2024-03-25 22:12:47 +0100 | |
---|---|---|
committer | 2024-03-25 22:12:47 +0100 | |
commit | 74373cb086da6097eae7d2e8bd6348aaf7c43857 (patch) | |
tree | 8b179190049b8611a18e29e13e7379d5c0f9b8b4 /widget/src/combo_box.rs | |
parent | f0ae9a0c38c2532220a7460916604914db94c078 (diff) | |
download | iced-74373cb086da6097eae7d2e8bd6348aaf7c43857.tar.gz iced-74373cb086da6097eae7d2e8bd6348aaf7c43857.tar.bz2 iced-74373cb086da6097eae7d2e8bd6348aaf7c43857.zip |
Make defaults of composite widgets configurable
Diffstat (limited to 'widget/src/combo_box.rs')
-rw-r--r-- | widget/src/combo_box.rs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/widget/src/combo_box.rs b/widget/src/combo_box.rs index df5358d6..e4f4a41f 100644 --- a/widget/src/combo_box.rs +++ b/widget/src/combo_box.rs @@ -64,7 +64,8 @@ where on_selected: impl Fn(T) -> Message + 'static, ) -> Self { let text_input = TextInput::new(placeholder, &state.value()) - .on_input(TextInputEvent::TextChanged); + .on_input(TextInputEvent::TextChanged) + .class(Theme::default_input()); let selection = selection.map(T::to_string).unwrap_or_default(); @@ -77,7 +78,7 @@ where on_option_hovered: None, on_input: None, on_close: None, - menu_class: <Theme as menu::Catalog>::default(), + menu_class: <Theme as Catalog>::default_menu(), padding: text_input::DEFAULT_PADDING, size: None, } @@ -752,7 +753,17 @@ where } /// The theme catalog of a [`ComboBox`]. -pub trait Catalog: text_input::Catalog + menu::Catalog {} +pub trait Catalog: text_input::Catalog + menu::Catalog { + /// The default class for the text input of the [`ComboBox`]. + fn default_input<'a>() -> <Self as text_input::Catalog>::Class<'a> { + <Self as text_input::Catalog>::default() + } + + /// The default class for the menu of the [`ComboBox`]. + fn default_menu<'a>() -> <Self as menu::Catalog>::Class<'a> { + <Self as menu::Catalog>::default() + } +} impl Catalog for Theme {} |