Author Topic: Suggestion on how to improve LCL/Lazarus scrolling on macOS  (Read 184 times)


  • New member
  • *
  • Posts: 8
Suggestion on how to improve LCL/Lazarus scrolling on macOS
« on: December 23, 2020, 10:34:32 pm »
I noticed that for controls that implement scrolling themselves through OnMouseWheel, scrolling is extremely poor on macOS. While the OS gives very detailed events, OnMouseWheel only sends out scroll events with +/120. I assume that was done for compatibility with Windows, but even Windows itself has moved away from this already: When using a Microsoft precision touchpad, numbers can be much more fine grained. Microsoft specifically states that apps should not rely on the number 120 :-)

In the Cocoa part of LCL, the conversion is happening here:

I tried patching this up (in a hacky way) like this:

  if dy <> 0 then
    Msg.Msg := LM_MOUSEWHEEL;
    Msg.WheelDelta := Round(dy * 3);
  if dx <> 0 then
    Msg.Msg := LM_MOUSEHWHEEL;
    // see "deltaX" documentation.
    // on macOS: -1 = right, +1 = left
    // on LCL:   -1 = left,  +1 = right
    Msg.WheelDelta := Round(-dx);

And scrolling was MUCH improved. For best effects it helps if the custom control actually implements pixel-perfect scrolling, but even those that just handle line-based scrolling things are better. Best example: The Lazarus editor itself, which I found almost unusable before but with that patch feels closer to other apps (pixel-perfect scrolling would make it really good, but that's a much bigger undertaking).

I filed a bug about it ( that explains why the constant 3. Also attached a test program there.

I'm hoping for more opinions on this, especially from the people who are familiar with the Cocoa side of LCL. Thanks!


TinyPortal © 2005-2018