Skip to content

Commit

Permalink
Update mouse_wheel_event()
Browse files Browse the repository at this point in the history
As per emilk/egui#4524.

Tested locally in `v0x0g/rayna`
  • Loading branch information
v0x0g committed Jul 7, 2024
1 parent 120edb1 commit 6a08546
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,15 @@ impl EguiMq {
/// Call from your [`miniquad::EventHandler`].
pub fn mouse_wheel_event(&mut self, dx: f32, dy: f32) {
let delta = egui::vec2(dx, dy);
let modifiers = self.egui_input.modifiers;

let event = if self.egui_input.modifiers.ctrl {
// Treat as zoom instead:
egui::Event::Zoom((delta.y / 200.0).exp())
} else {
egui::Event::Scroll(delta)
};
self.egui_input.events.push(event);
self.egui_input.events.push(
egui::Event::MouseWheel {
modifiers,
unit: egui::MouseWheelUnit::Line,
delta
}
);
}

/// Call from your [`miniquad::EventHandler`].
Expand Down

0 comments on commit 6a08546

Please sign in to comment.