Immediate-Mode-UI / Nuklear

A single-header ANSI C immediate mode cross-platform GUI library
https://immediate-mode-ui.github.io/Nuklear/doc/index.html
Other
9.06k stars 542 forks source link

Touch to Scroll #519

Open FrostKiwi opened 1 year ago

FrostKiwi commented 1 year ago

I would like to have touch to scroll working, for usage on touch screens. You know, how you can effortlessly just scroll up and down on a webpage with a phone. So for a flawless experience, with an enlarged scrollbar being used for scrolling though. As a workaround it is trivial to remap to fingers moving to -> nk_input_scroll() But it just isn't the same as proper one finger touch to scroll.

The logic needed for this is rather simple I imagine. The logic for this is "If mouse is not hovering over something that can be interacted with, then click + drag distance affects ctx.input.scroll_delta". However, whilst there are a bunch of functions to test whether the mouse is over an intractable rectangle, I don't know how to test for the opposite. There is a nk_window_is_any_hovered() but no nk_window_is_any_clickable_thingy_hovered().

Anyone have an idea how to test for "Is the current mouse click over something that can be interacted with?"

ronaaron commented 1 month ago

What I would like is to be able, on a mobile device, use the typical finger swipe to scroll a list or combo box, instead of (or in addition to) a scroll-bar. I don't see any such option, though perhaps it would be possible to intercept e.g. SDL_FINGERMOTION and use it to emulate "flinging".