From 884c3b72d6bbdb5c9652a28dc2c24b2931ea8ce8 Mon Sep 17 00:00:00 2001 From: Kaur Kuut Date: Sun, 17 May 2020 14:25:13 +0300 Subject: [PATCH] Add hot state updating via wheel events. --- CHANGELOG.md | 2 ++ druid/src/core.rs | 22 ++++++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b5530643c..fa62f99d3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -95,6 +95,7 @@ This means that druid no longer requires cairo on macOS and uses Core Graphics i - X11: Support key and mouse button state. ([#920] by [@jneem]) - Routing `LifeCycle::FocusChanged` to descendant widgets. ([#925] by [@yrns]) - Built-in open and save menu items now show the correct label and submit the right commands. ([#930] by [@finnerale]) +- Wheel events now properly update hot state. ([#951] by [@xStrom]) ### Visual @@ -192,6 +193,7 @@ This means that druid no longer requires cairo on macOS and uses Core Graphics i [#940]: https://github.com/xi-editor/druid/pull/940 [#942]: https://github.com/xi-editor/druid/pull/942 [#943]: https://github.com/xi-editor/druid/pull/943 +[#951]: https://github.com/xi-editor/druid/pull/951 ## [0.5.0] - 2020-04-01 diff --git a/druid/src/core.rs b/druid/src/core.rs index 2e29c64286..f93331b6e6 100644 --- a/druid/src/core.rs +++ b/druid/src/core.rs @@ -658,6 +658,22 @@ impl> WidgetPod { mouse_event.pos -= rect.origin().to_vec2(); Event::MouseMove(mouse_event) } + Event::Wheel(mouse_event) => { + WidgetPod::set_hot_state( + &mut self.inner, + child_ctx.command_queue, + child_ctx.base_state, + child_ctx.window_id, + rect, + Some(mouse_event.pos), + data, + env, + ); + recurse = had_active || child_ctx.base_state.is_hot; + let mut mouse_event = mouse_event.clone(); + mouse_event.pos -= rect.origin().to_vec2(); + Event::Wheel(mouse_event) + } Event::KeyDown(e) => { recurse = child_ctx.has_focus(); Event::KeyDown(*e) @@ -670,12 +686,6 @@ impl> WidgetPod { recurse = child_ctx.has_focus(); Event::Paste(e.clone()) } - Event::Wheel(wheel_event) => { - recurse = had_active || child_ctx.base_state.is_hot; - let mut wheel_event = wheel_event.clone(); - wheel_event.pos -= rect.origin().to_vec2(); - Event::Wheel(wheel_event) - } Event::Zoom(zoom) => { recurse = had_active || child_ctx.base_state.is_hot; Event::Zoom(*zoom)