[fpc-pascal] Mouse, scroll wheel support?
michalis.kambi at gmail.com
Wed Jun 29 11:04:55 CEST 2016
2016-06-28 15:05 GMT+02:00 John Youngquist <johnyq999 at gmail.com>:
> Is there a non Lazarus means of accessing the mouse, and scroll wheel?
> I have an app that uses some old driver which doesn't address the wheel.
> I'm trying to make the wheel work. I have tried SDL and the demo code works
> but it seems to work only in an externally created window. I can't find any
> documentation for it nor can I post on the forum.
Accessing events like mouse and keyboard always requires to use some
API. It may be high-level API like Lazarus LCL or SDL (or my
TCastleWindow), it may be lower-level like GTK, or WinAPI, or even
Xlib. For all these APIs, the exact answer "how to read mouse wheel
events" is different:)
In most of them, you can only read mouse events that reach windows
that you yourself created (windows for which you have a "handle" or
some equivalent). If you want to get mouse wheel events that occur
above *any* window --- you may be out of luck (or you may be able to
use some hack in the lowest-level APIs, like WinAPI or Xlib, but I
can't help you more here).
For SDL, the way to read mouse wheel is to
- either use https://wiki.libsdl.org/SDL_MouseWheelEvent (but it seems
SDL_MOUSEWHEEL is not translated in FPC SDL headers, neither in
original jedi-sdl headers),
- or you can watch for event types SDL_MOUSEBUTTONDOWN ,
SDL_MOUSEBUTTONUP with button set to SDL_BUTTON_WHEELUP or
SDL_BUTTON_WHEELDOWN (this works without problems for me, trying on
old jedi-sdl examples with FPC SDL units).
More information about the fpc-pascal