In Delphi 10.2.3, the TFramedVertScrollBox component automatically supports vertical kinetic scrolling using Touch (tested in Android).
However, by default the only way to scroll using a mouse is the scrollbar (which I am hiding).
Is there a way to have the mouse events hook into the touch's kinetic scroll code?
If not, is my only choice to manually code my own kinetic scroll algorithm?
The documentation confirms your observation regarding automatic gesture response on Android
and other mobile targets:
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.
On Windows it is very simple to achieve the same effect by setting properties of FramedVertScrollBox1.AniCalculations
. Because AniCalculations
is not published, it can't be setup in the Object Inspector
but f.ex. in an OnCreate
event of the form:
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;
The ShowScrollbars
property can be set to False
and the content of the FramedVertScrollBox1
moves "inertially" when dragged vertically with the mouse.