diff options
-rw-r--r-- | core/src/widget/operation/focusable.rs | 27 | ||||
-rw-r--r-- | widget/src/lib.rs | 2 | ||||
-rw-r--r-- | widget/src/scrollable.rs | 2 |
3 files changed, 29 insertions, 2 deletions
diff --git a/core/src/widget/operation/focusable.rs b/core/src/widget/operation/focusable.rs index 8f66e575..a1327bc1 100644 --- a/core/src/widget/operation/focusable.rs +++ b/core/src/widget/operation/focusable.rs @@ -61,6 +61,33 @@ pub fn focus<T>(target: Id) -> impl Operation<T> { Focus { target } } +/// Produces an [`Operation`] that unfocuses the focused widget. +pub fn unfocus<T>() -> impl Operation<T> { + struct Unfocus; + + impl<T> Operation<T> for Unfocus { + fn focusable( + &mut self, + _id: Option<&Id>, + _bounds: Rectangle, + state: &mut dyn Focusable, + ) { + state.unfocus(); + } + + fn container( + &mut self, + _id: Option<&Id>, + _bounds: Rectangle, + operate_on_children: &mut dyn FnMut(&mut dyn Operation<T>), + ) { + operate_on_children(self); + } + } + + Unfocus +} + /// Produces an [`Operation`] that generates a [`Count`] and chains it with the /// provided function to build a new [`Operation`]. pub fn count() -> impl Operation<Count> { diff --git a/widget/src/lib.rs b/widget/src/lib.rs index b8cfa98f..31dcc205 100644 --- a/widget/src/lib.rs +++ b/widget/src/lib.rs @@ -12,7 +12,6 @@ mod action; mod column; mod mouse_area; mod pin; -mod row; mod space; mod stack; mod themer; @@ -28,6 +27,7 @@ pub mod pick_list; pub mod pop; pub mod progress_bar; pub mod radio; +pub mod row; pub mod rule; pub mod scrollable; pub mod slider; diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs index 8adf5136..fe71fd6b 100644 --- a/widget/src/scrollable.rs +++ b/widget/src/scrollable.rs @@ -753,7 +753,7 @@ where if let InputMethod::Open { position, .. } = shell.input_method_mut() { - *position = *position + translation; + *position = *position - translation; } } }; |