TFramedVertScrollBox 用鼠标动态滚动(非触摸)

TFramedVertScrollBox kinetic scroll with the mouse (not touch)

在Delphi 10.2.3中,TFramedVertScrollBox组件自动支持使用Touch的垂直动态滚动(在Android中测试)。

但是,默认情况下,使用鼠标滚动的唯一方法是滚动条(我隐藏了它)。

有没有办法让鼠标事件挂钩到触摸的动态滚动代码中?
如果没有,我唯一的选择是手动编写我自己的动力学滚动算法吗?

documentation 证实了您对 Android 和其他移动目标的自动手势响应的观察:

Under iOS, Mac OS, and Android, a scroll view responds to the speed and direction of gestures to reveal content in a way that feels natural to people. FireMonkey provides the InertialMovement unit emulating such smooth inertial moving of a scroll view under Windows.

在Windows上,通过设置FramedVertScrollBox1.AniCalculations的属性来达到同样的效果非常简单。因为AniCalculations没有发布,所以不能设置在Object Inspector但是f.ex。在以下形式的 OnCreate 事件中:

procedure TForm1.FormCreate(Sender: TObject);
begin
  // Enable scrolling by mouse or gesture
  FramedVertScrollBox1.AniCalculations.TouchTracking := [ttVertical];
  // Enable inertial movement
  FramedVertScrollBox1.AniCalculations.Animation := True;
  // Set deceleration rate
  FramedVertScrollBox1.AniCalculations.DecelerationRate :=  DecelerationRateNormal;
end;

ShowScrollbars属性可设置为FalseFramedVertScrollBox1的内容在鼠标垂直拖动时移动"inertially"