diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c5bc91..1817daa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 apps. - The default logging output has been trimmed to only show errors for wgpu, winit, and naga. Thanks to @bluenote10 for the feedback! +- `WrapperWidget::activate`'s default implementation now activates the wrapped + widget. ### Fixed @@ -82,6 +84,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `Resize` now performs a second layout pass, if necessary, to ensure that children widgets have an opportunity to fill the resized area. Additionally, the first SizeToFit measurement will be performed with the minimum dimension. +- When a keyboard-activated widget activates another widget during its callback, + the key-up event now sends the deactivate event to the finally-activated + widget. ### Added diff --git a/src/tree.rs b/src/tree.rs index d9176fd..caa84f9 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -306,6 +306,12 @@ impl Tree { self.data.lock().active } + pub(crate) fn active_widget_id(&self) -> Option { + let data = self.data.lock(); + + data.active.map(|node| data.nodes[node].widget.id()) + } + pub(crate) fn hovered_widget(&self) -> Option { self.data.lock().hover } diff --git a/src/widget.rs b/src/widget.rs index 8120aa3..9616928 100644 --- a/src/widget.rs +++ b/src/widget.rs @@ -674,7 +674,10 @@ pub trait WrapperWidget: Debug + Send + 'static { /// The widget has become the active widget. #[allow(unused_variables)] - fn activate(&mut self, context: &mut EventContext<'_>) {} + fn activate(&mut self, context: &mut EventContext<'_>) { + let child = self.child_mut().mounted(context); + context.for_other(&child).activate(); + } /// The widget is no longer active. #[allow(unused_variables)] diff --git a/src/window.rs b/src/window.rs index 1275f0c..a064726 100644 --- a/src/window.rs +++ b/src/window.rs @@ -1430,7 +1430,7 @@ where kludgine, ) .activate(); - self.keyboard_activated = Some(default.id()); + self.keyboard_activated = self.tree.active_widget_id(); } } else if let Some(keyboard_activated) = self .keyboard_activated