diff options
| author | Matthias Melcher <github@matthiasm.com> | 2023-10-13 13:59:01 +0200 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2023-10-13 13:59:01 +0200 |
| commit | 58b13b868e9be35e2b516a72a736b8c61178467a (patch) | |
| tree | 3e28043094070c79871fe35c67943581e307d738 /src | |
| parent | b1321bb97e254a5aa4d5ed6eef03d89a3892d1f9 (diff) | |
FLUID: allow mousewheel events on coordinate input
MACOS: make sure that even small mouse wheel deltas count at least as 1 unit
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_cocoa.mm | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 744b831d7..3927ebb45 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -991,8 +991,13 @@ static void cocoaMouseWheelHandler(NSEvent *theEvent) Fl::first_window(window); // Under OSX, mousewheel deltas are floats, but fltk only supports ints. float s = Fl::screen_driver()->scale(0); - int dx = roundf([theEvent deltaX] / s); - int dy = roundf([theEvent deltaY] / s); + float edx = [theEvent deltaX]; + float edy = [theEvent deltaY]; + int dx = roundf(edx / s); + int dy = roundf(edy / s); + // make sure that even small wheel movements count at least as one unit + if (edx>0.0f) dx++; else if (edx<0.0f) dx--; + if (edy>0.0f) dy++; else if (edy<0.0f) dy--; // allow both horizontal and vertical movements to be processed by the widget if (dx) { Fl::e_dx = -dx; |
