Handling scroll wheel events
Cameron Cawley (3514) 158 posts |
What would be the best way of handling scroll wheel events in an application? For context, I’m looking at implementing scroll wheel events in SDL 1.2, however it appears that Scroll_Request WIMP events are only sent when the window has scroll bars (which isn’t the case with SDL), and using “OS_Pointer”,2 in a simple test program fails to work on both RISC OS 3.7 and 5.27 (21-Sep-19). Any suggestions? |
Jeffrey Lee (213) 6048 posts |
Proper scroll wheel support in RISC OS 5 is a relatively recent thing, only arriving in April this year. The behaviour should be the same as RISC OS Select, both in terms of WindowScroll / Wimp messages and OS_Pointer 2, OS_Mouse, and Event 21,4. So if WindowScroll is available, I’d recommend that you track scroll requests in the Wimp by configuring the window to receive extended scroll requests, and when single-tasking use either poll OS_Pointer 2 or listen out for Event 21,4. If WindowScroll isn’t available, you’ve got problems. Older versions of RISC OS 5 used this code – in the Wimp, only regular Scroll requests are used, and are only guaranteed to be delivered to windows with scroll bars (older versions of USBDriver did deliver them to windows without scroll bars, but that was changed when we had reports of horizontal scrolling breaking filer windows). Outside of the Wimp, you should be able to get the events by listening out for PointerV 9. Another thing to watch out for is that for many years there was a kernel bug which can cause OS_Pointer to crash if you called it with an unsupported reason code. So you should only call OS_Pointer 2 if you know the kernel isn’t buggy, and the easiest way of checking if the kernel isn’t buggy is probably to check if the WindowScroll module is present. |
Cameron Cawley (3514) 158 posts |
Thanks for your advice. I’ve implemented scroll wheel support in windowed mode alongside additional mouse buttons, and the relevant commit is now in Mercurial: https://hg.libsdl.org/SDL/rev/95be7982bc83 . I haven’t implemented scroll wheel support in full screen mode, though, since I’m not sure what the best way to handle situations where the position wraps around. |