frang75 / nappgui_src

SDK for building cross-platform desktop apps in ANSI-C
https://www.nappgui.com
MIT License
502 stars 50 forks source link

Horizontal touchpad scrolling on macOS #99

Open turbo opened 9 months ago

turbo commented 9 months ago

Using macOS Sonoma (Apple Silicon), in none of the demos that have a horizontally scrolling container (e.g. the table demo in GuiHello) work with touchpad scrolling. I can scroll vertically, I can even scroll horizontally when the cursor hovers the bottom scrollbar, but if the cursor is in the view, only vertical scrolling functions.

Here's a demo showing what I mean. I try to do three things:

  1. scroll vertically (works)
  2. scroll horizontally with cursor inside the view (doesn't work)
  3. scroll horizontally by hovering the bottom scrollbar and moving my fingers vertically (works, but is very odd behavior)

https://github.com/frang75/nappgui_src/assets/8023543/367bcabb-2d3c-498c-a159-84f548926de4

frang75 commented 9 months ago

Hi @turbo ! Thanks for download and test NAppGUI.

Yes it's true. Horizontal mouse scrolling is disabled, not only for macOS, also for Windows/Linux. When I was developing View support I was bothered by the horizontal micro-scrolls produced by the MagicMouse. It's easy to solve. I will upload it to GitHub shortly.

turbo commented 9 months ago

Thanks! Yes, I think macOS is sufficiently different to warrant a change. The behaviour I'm used to from other macOS apps is that once you start to scroll in a particular direction, it will lock into that direction. But if you start with a diagonal gesture, it'll move more freely. That means there are usually no micro-scrolls happening once you start to scroll horizontally. That might be unique to macOS, but probably also applies to modern Windows laptops with Windows Precision Touchpad drivers.

frang75 commented 9 months ago

Its a good tip. Set the scroll type based on first gesture. Perhaps I'll also add some user configuration for special kind of views.

enum mouse_motion_t
{
   ekMOUSE_FIXED_HORIZONTAL,
   ekMOUSE_FIXED_VERTICAL,
   ekMOUSE_FREE,
   ekMOUSE_BY_GESTURE (default)
};

view_mouse_config(View *view, mouse_motion_t motion);
turbo commented 9 months ago

That's a great idea. The option to have "free" is useful for some views (e.g. a map), and the default makes sense.