From eb53016d714de51dbe7be648421c84a570f28ebb Mon Sep 17 00:00:00 2001 From: Floyd Wang Date: Fri, 9 Aug 2024 11:37:13 +0800 Subject: [PATCH] Use `ViewContext` instead of `WindowContext` for input affix (#126) --- crates/ui/src/input/input.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/ui/src/input/input.rs b/crates/ui/src/input/input.rs index 2fab373d..e5accec0 100644 --- a/crates/ui/src/input/input.rs +++ b/crates/ui/src/input/input.rs @@ -112,8 +112,8 @@ pub struct TextInput { text: SharedString, history: History, blink_cursor: Model, - prefix: Option AnyElement + 'static>>, - suffix: Option AnyElement + 'static>>, + prefix: Option) -> AnyElement + 'static>>, + suffix: Option) -> AnyElement + 'static>>, loading: bool, placeholder: SharedString, selected_range: Range, @@ -212,7 +212,7 @@ impl TextInput { /// Set the prefix element of the input field. pub fn set_prefix(&mut self, builder: F, cx: &mut ViewContext) where - F: Fn(&WindowContext) -> E + 'static, + F: Fn(&ViewContext) -> E + 'static, E: IntoElement, { self.prefix = Some(Box::new(move |cx| builder(cx).into_any_element())); @@ -222,7 +222,7 @@ impl TextInput { /// Set the suffix element of the input field. pub fn set_suffix(&mut self, builder: F, cx: &mut ViewContext) where - F: Fn(&WindowContext) -> E + 'static, + F: Fn(&ViewContext) -> E + 'static, E: IntoElement, { self.suffix = Some(Box::new(move |cx| builder(cx).into_any_element())); @@ -238,7 +238,7 @@ impl TextInput { /// Set the prefix element of the input field, for example a search Icon. pub fn prefix(mut self, builder: F) -> Self where - F: Fn(&mut WindowContext) -> E + 'static, + F: Fn(&mut ViewContext) -> E + 'static, E: IntoElement, { self.prefix = Some(Box::new(move |cx| builder(cx).into_any_element())); @@ -248,7 +248,7 @@ impl TextInput { /// Set the suffix element of the input field, for example a clear button. pub fn suffix(mut self, builder: F) -> Self where - F: Fn(&mut WindowContext) -> E + 'static, + F: Fn(&mut ViewContext) -> E + 'static, E: IntoElement, { self.suffix = Some(Box::new(move |cx| builder(cx).into_any_element()));