Gesture Support in Metropolis UI Applications

From RAD Studio
Jump to: navigation, search

Go Up to Developing Metropolis UI Applications

Metropolis UI applications support the following gestures:

Custom gestures are not supported in Metropolis UI applications.

Gesture support in FireMonkey is provided through two different Windows APIs:

  • RealTimeStylus API for standard (single-touch) gestures
  • Windows Touch API for interactive (multi-touch) gestures

Support for Windows 8 Interactive Gestures

When you run a Metropolis UI application on Windows 8, most of the Windows 8 interactive gestures are supported, as follows:

Windows 8 Gesture Support in Metropolis UI Applications


Supported as a click, translated by Windows 8

Press and Hold

Not supported


Not supported *


Not supported *


Supported as Rotate


Supported as Zoom (the EventInfo.Distance value decreases)


Supported as Zoom (the EventInfo.Distance value increases)

* The Slide and Swipe gestures can be simulated using the Pan gesture in Metropolis UI applications, by tracking the location and direction of the pan movement.

The supported interactive gestures are described in:

For more information about equivalent interactive gestures, see

Handling Gestures with Windows 8

In Windows 8, when the RealTimeStylus is enabled for a window, all gestures are sent through the MS Windows 8 RealTimeStylus API, and the Windows Touch API does not report any events.

To workaround this issue, a global flag has been added to FireMonkey that allows the RealTimeStylus API to be disabled. When the RealTimeStylus API is disabled, FireMonkey does not detect standard gestures. Instead, the gesture events from the Windows Touch API are reported individually through the OnGesture event handler.

You can interpret these events to determine the gesture that was made by the user. A Windows Touch gesture is reported as multiple events, beginning with one event with the TGestureEventInfo.Flag containing gfBegin, and ending with an event containing gfEnd. For more information, see FMX.Types.TInteractiveGestureFlag.

To enable the reporting of Windows Touch events, and to enable interactive gestures, the following code should be added to the beginning of the main program file:


TPlatformServices.Current.GlobalFlags.Add(GlobalDisableStylusGestures, True);


TPlatformServices::Current->GlobalFlags->Add(GlobalDisableStylusGestures, true);

You should also add FMX.Platform and FMX.Consts to your uses section or #include statements.

This workaround is not required on Windows 7 and might not be required in the final release of Windows 8.

See Also