Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

[macOS] Fix mouse precise scrolling.

Pāvels Nadtočajevs0ce70e116b57
diff --git a/platform/macos/godot_content_view.mm b/platform/macos/godot_content_view.mm
index 844f918de2c..b3241a25460 100644
--- a/platform/macos/godot_content_view.mm
+++ b/platform/macos/godot_content_view.mm
@@ -918,8 +918,16 @@
}
if ([event phase] != NSEventPhaseNone || [event momentumPhase] != NSEventPhaseNone) {
+ // Touchpad with inertial scrolling, keep deltas as is.
[self processPanEvent:event dx:delta_x dy:delta_y];
} else {
+ // Mouse scroll wheel.
+ if ([event hasPreciseScrollingDeltas]) {
+ // Deltas are in pixels, convert to lines.
+ delta_x /= 32.0;
+ delta_y /= 32.0;
+ }
+
double delta_x_abs = Math::abs(delta_x);
double delta_y_abs = Math::abs(delta_y);