From 74373cb086da6097eae7d2e8bd6348aaf7c43857 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 25 Mar 2024 22:12:47 +0100 Subject: Make defaults of composite widgets configurable --- widget/src/combo_box.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'widget/src/combo_box.rs') 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: ::default(), + menu_class: ::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>() -> ::Class<'a> { + ::default() + } + + /// The default class for the menu of the [`ComboBox`]. + fn default_menu<'a>() -> ::Class<'a> { + ::default() + } +} impl Catalog for Theme {} -- cgit