FMX.TapAndHold Sample

From RAD Studio Code Examples
Jump to: navigation, search

This sample use the TGestureManager class to demonstrate how to use long tap gestures.


You can find the TapAndHold sample project at:

  • Start | Programs | Embarcadero RAD Studio Alexandria | Samples and then navigate to:
    • Object Pascal\Mobile Snippets\InteractiveGestures\TapAndHold
    • CPP\Mobile Snippets\InteractiveGestures\TapAndHold
  • Subversion Repository:
    • You can find Delphi and C++ code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.


The TapAndHold sample demonstrates how to use long tap gestures on an iOS or Android device. The sample demonstrates how to detect and act with long tap gestures.

How to Use the Sample

  1. Navigate to one of the locations given above and open:
    • Delphi: TapAndHold.dproj.
    • C++: TapAndHold.cbproj.
  2. Select the target platform, iOS and Android supported.
  3. Press F9 or choose Run > Run.
  4. Press the screen with a finger. Hold pressed to see a message with the tap location and the date-time information.


File in Delphi File in C++ Contains



The project itself.



The main form where the components are located.


TapAndHoldPCH.h, TapAndHold.cpp

Used to define and implement the sample.



Further information about the sample.


  • The sample uses TImage to display and define a 2D image component.
  • The TGestureManager class is used to manage all the touch and gesturing functionalities of the application.
  • The TGestureEventInfo describes a gesture event. It is a record that contains information about a gesture event. The TGestureEvent type passes a TGestureEventInfo record to the user code.

The sample shows a picture. When the user holds press a finger on the picture, the TGestureEventInfo detects a long tap gesture and the screen shows a message with the location and date-time information of the long tap. The sample uses the field Location of the TGestureEventInfo to show the screen tap location and the FormatDateTime to show the date-time value of the long tap.


See Also