RAD Studio 2010 - Touch & Gestures Part 2

Posted by on in Blogs
One of the integrated touch features of the VCL in RAD Studio 2010 is interactive multi-touch gestures. We call them InteractiveGestures because they fire the OnGesture event continuosly as the gesture is performed, allowing UI to be updated to reflect zooming, panning and rotation. InteractiveGestures are accessed from the new Touch property, as seen below:



There are 5 InteractiveGestures: zoom, pan, rotate, two finger tap and press and tap. Responding to an InteractiveGesture is as simple as adding an event handler for the OnGesture event.



The event handler is passed a TGestureEventInfo record which contains information about the gesture, such as location (point), angle, distance (between points) and inertia vector. When the option igoPanInertia is selected, OnGesture is called repeatedly with synthesized locations that gradually get closer together to simluate gravity when you let go.

Here's an example of how to implement panning for a custom control:


By default VCL handles multi-touch panning in scrollable controls, including forms. The code snippet above is taken from TScrollingWinControl, and any descendant controls will automatically respond to panning when the AutoScroll property is True.


Check out more tips and tricks in this development video: