diff options
author | 2022-07-28 03:53:47 +0200 | |
---|---|---|
committer | 2022-07-28 03:53:47 +0200 | |
commit | 52f84e51e90db1c324310565f2aff8b7e6987cba (patch) | |
tree | 721ef64dd91e0aca0e490971c8e1ee44ca912957 /native/src/widget/operation | |
parent | 80688689aa4b15bc23824df899974a9094a77b07 (diff) | |
download | iced-52f84e51e90db1c324310565f2aff8b7e6987cba.tar.gz iced-52f84e51e90db1c324310565f2aff8b7e6987cba.tar.bz2 iced-52f84e51e90db1c324310565f2aff8b7e6987cba.zip |
Implement `Widget::operate` for `TextInput`
Diffstat (limited to '')
-rw-r--r-- | native/src/widget/operation.rs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/native/src/widget/operation.rs b/native/src/widget/operation.rs index b6c108e0..2cfba005 100644 --- a/native/src/widget/operation.rs +++ b/native/src/widget/operation.rs @@ -5,7 +5,7 @@ pub trait Operation<T> { fn container( &mut self, id: Option<&Id>, - operate_on_children: &dyn Fn(&mut dyn Operation<T>), + operate_on_children: &mut dyn FnMut(&mut dyn Operation<T>), ); fn focusable( @@ -37,14 +37,12 @@ pub fn focus<T>(target: Id) -> impl Operation<T> { state: &mut dyn state::Focusable, id: Option<&Id>, ) { - if state.is_focused() { - match id { - Some(id) if id == &self.target => { - state.focus(); - } - _ => { - state.unfocus(); - } + match id { + Some(id) if id == &self.target => { + state.focus(); + } + _ => { + state.unfocus(); } } } @@ -52,7 +50,7 @@ pub fn focus<T>(target: Id) -> impl Operation<T> { fn container( &mut self, _id: Option<&Id>, - operate_on_children: &dyn Fn(&mut dyn Operation<T>), + operate_on_children: &mut dyn FnMut(&mut dyn Operation<T>), ) { operate_on_children(self) } |