Sign in Join
Wiki copytemporary

macOS Gestures: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: macOS Gestures

OldNewLine
1+*(macOS only)*
2+
3+## Overview
4+
5+The Gestures unit provides convenient Free Pascal classes for handling macOS gestures.
6+
7+Currently only the magnification gesture is implemented, but others can be implemented easily in a similar way.
8+
9+## Usage Example
10+
11+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:
12+
13+``` pascal
14+uses
15+ Gestures;
16+
17+type
18+ TForm_Main = class(TForm)
19+ private
20+ Gesture: TMagnificationGesture;
21+ InitialScale: Double;
22+ end;
23+
24+procedure TForm_Main.FormCreate(Sender: TObject);
25+begin
26+ Gesture := TMagnificationGesture.Create(Self);
27+ Gesture.Control := MyScalableControl;
28+ Gesture.OnGesture := @MagnificationGestureGesture;
29+end;
30+
31+procedure TForm_Main.MagnificationGestureGesture(Sender: TMagnificationGesture;
32+ State: TGestureState; Magnification: Double);
33+begin
34+ case State of
35+ gsBegan:
36+ InitialScale := MyScalableControl.Scale;
37+
38+ gsChanged:
39+ if Magnification > 0 then
40+ MyScalableControl.Scale := InitialScale * (1 + Magnification)
41+ else
42+ MyScalableControl.Scale := InitialScale / (1 - Magnification);
43+ end;
44+end;
45+```
46+
47+## Author
48+
49+Yuri Plashenkov
50+
51+## License
52+
53+This package is licensed under the [MIT license](https://github.com/plashenkov/macOS-gestures-FPC/blob/main/LICENSE.md).
54+
55+## Download
56+
57+The Gestures unit may be downloaded from [GitHub](https://github.com/plashenkov/macOS-gestures-FPC).
58+
59+## External links
60+
61+- [Apple: Trackpad gestures](https://support.apple.com/en-au/HT204895)
62+- [Apple: Gestures](https://developer.apple.com/documentation/appkit/gestures)
63+
64+---
65+*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](/wiki-contact).*
66+Category: Code Snippets
67+Category: Platform-sensitive development
68+Category: macOS

Back to history