diff options
author | 2019-10-29 19:00:46 +0100 | |
---|---|---|
committer | 2019-10-29 19:00:46 +0100 | |
commit | bd5d871eb6630bc8f987d72c771032f878fb91b6 (patch) | |
tree | 528784f51a84abb0863590864a4af8f854d462e2 /winit/src/application.rs | |
parent | 29588f604af66fb4911f791c0c402fccd30ba64b (diff) | |
download | iced-bd5d871eb6630bc8f987d72c771032f878fb91b6.tar.gz iced-bd5d871eb6630bc8f987d72c771032f878fb91b6.tar.bz2 iced-bd5d871eb6630bc8f987d72c771032f878fb91b6.zip |
Handle touchpad scroll events
Diffstat (limited to 'winit/src/application.rs')
-rw-r--r-- | winit/src/application.rs | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/winit/src/application.rs b/winit/src/application.rs index 855968aa..c8748199 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -123,6 +123,7 @@ pub trait Application { .. } => match window_event { WindowEvent::CursorMoved { position, .. } => { + // TODO: Remove when renderer supports HiDPI let physical_position = position.to_physical(window.hidpi_factor()); @@ -143,10 +144,28 @@ pub trait Application { delta_y, ) => { events.push(Event::Mouse( - mouse::Event::WheelScrolled { delta_x, delta_y }, + mouse::Event::WheelScrolled { + delta: mouse::ScrollDelta::Lines { + x: delta_x, + y: delta_y, + }, + }, + )); + } + winit::event::MouseScrollDelta::PixelDelta(position) => { + // TODO: Remove when renderer supports HiDPI + let physical_position = + position.to_physical(window.hidpi_factor()); + + events.push(Event::Mouse( + mouse::Event::WheelScrolled { + delta: mouse::ScrollDelta::Pixels { + x: physical_position.x as f32, + y: physical_position.y as f32, + }, + }, )); } - _ => {} }, WindowEvent::CloseRequested => { *control_flow = ControlFlow::Exit; |