Skip to content

Commit

Permalink
fix egui zoom and side scroll events (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThundR67 committed Jul 30, 2023
1 parent 4b7600c commit fc9341c
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/gui/egui_gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,20 @@ impl GUI {
}
Event::Text(text) => Some(egui::Event::Text(text.clone())),
Event::MouseLeave => Some(egui::Event::PointerGone),
Event::MouseWheel { delta, handled, .. } => {
Event::MouseWheel {
delta,
handled,
modifiers,
..
} => {
if !handled {
Some(egui::Event::Scroll(egui::Vec2::new(
delta.0 as f32,
delta.1 as f32,
)))
Some(match modifiers.ctrl {
true => egui::Event::Zoom((delta.1 as f32 / 200.0).exp()),
false => egui::Event::Scroll(match modifiers.shift {
true => egui::Vec2::new(delta.1 as f32, delta.0 as f32),
false => egui::Vec2::new(delta.0 as f32, delta.1 as f32),
}),
})
} else {
None
}
Expand Down

0 comments on commit fc9341c

Please sign in to comment.