macOS Gestures
(macOS only)
Overview
The Gestures unit provides convenient Free Pascal classes for handling macOS gestures.
Currently only the magnification gesture is implemented, but others can be implemented easily in a similar way.
Usage Example
Let's assume your scalable control has a Scale property and you want to allow an end user to scale it by using the typical trackpad gesture. Here is the code:
uses
Gestures;
type
TForm_Main = class(TForm)
private
Gesture: TMagnificationGesture;
InitialScale: Double;
end;
procedure TForm_Main.FormCreate(Sender: TObject);
begin
Gesture := TMagnificationGesture.Create(Self);
Gesture.Control := MyScalableControl;
Gesture.OnGesture := @MagnificationGestureGesture;
end;
procedure TForm_Main.MagnificationGestureGesture(Sender: TMagnificationGesture;
State: TGestureState; Magnification: Double);
begin
case State of
gsBegan:
InitialScale := MyScalableControl.Scale;
gsChanged:
if Magnification > 0 then
MyScalableControl.Scale := InitialScale * (1 + Magnification)
else
MyScalableControl.Scale := InitialScale / (1 - Magnification);
end;
end;Author
Yuri Plashenkov
License
This package is licensed under the MIT license.
Download
The Gestures unit may be downloaded from GitHub.
External links
From the Free Pascal wiki, page "macOS Gestures", as it stood on 2020-11-29 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.
Talk about this page
Nobody has opened a bench for this page yet. Sign in to open one.
