Gesturing Overview
Go Up to Developing Applications with VCL Components
This section introduces the gesturing framework in RAD Studio and describes the following elements:
- Description of a gesture
- Component options for gesturing, including the standard gestures included in RAD Studio
- The OnGesture event
- The TGestureManager component, which you assign to your selected component in the Object Inspector
- The gesturing property editor and the Custom Gestures dialog box
- The Custom Gesture Designer
The videos RAD Studio 2010 Touch Gesture Capabilities and Delphi 2010, Using Touch Features and Gestures show you more about using gestures.
Contents |
What Is a Gesture
The RAD Studio gesturing framework enables your VCL applications to use gestures (alternative input mechanisms provided by touch hardware). A gesture is a motion performed using a touch device that triggers an event or an action. The primary touch devices used are finger and pen, but the mouse is also supported.
Component Options for Gesturing
Most components that derive from TControl publish the Touch property and have gesturing options. After you assign a GestureManager to your component, you can see the standard gesturing options in the Object Inspector, listed under the Touch property:
- Standard Gestures: The Standard library of gestures consists of over 30 gestures such as Left, Right, Scratchout, Circle, and ChevronUp. These gestures are associated with the enumeration Controls.TStandardGesture.
- For a descriptive list of all the standard gestures, see TStandardGesture Enum.
- Interactive Gestures" Interactive gestures are multi-touch gestures which trigger the OnGesture event continuously as the gesture is performed. These gestures include panning, zooming, rotating, two finger tap and press and tap. The EventInfo parameter of the OnGesture event provides additional information about the gesture being performed such as location of touch point, angle of rotation, inertia of a panning motion etc. Interactive gestures require a multi-touch enabled operating system and can only be invoked by a touch input device.
The OnGesture Event
Every VCL component that supports gesturing also supports the OnGesture event, which is triggered in two cases:
- Any time the gesture engine recognizes a gesture, as follows:
- Standard gestures (the library of 34 gestures available through the Gesture Manager)
- Your own custom gestures (created using the Custom Gesture Designer)
- Registered gestures (gestures stored in a package or DLL)
- Any time your application uses an Interactive Gesture
OnGesture is triggered after the gesture engine attempts a match. The event is also fired when the match fails with a gesture ID, which you can handle.
You associate actions with specific gestures in the Object Inspector. For consistency, use the same gestures for the same actions across all applicable components in your application and between your applications.
For more information, see Controls.TControl.OnGesture.
The TGestureManager Component
Every component that uses gesturing needs to be associated with a Gesture Manager. In selecting the component to use, keep in mind that large components (such as panel and list components) work better with gesturing, while smaller components like buttons or checkboxes are not well adapted to using gestures.
First, add a TGestureManager to your panel or list component (on the Tool Palette, select TGestureManager from the Gestures category).
The abstract base for all gesture manager components is Controls.TCustomTouchManager.GestureManager.
Selecting Gestures with the Gesturing Property Editor
You can access the gesturing property editor when a GestureManager is assigned to the currently selected design element. On the Object Inspector, open the Touch node and then the Gestures node. To open the gesturing property editor, click the ellipsis (
) associated with the Gestures node. While you work, you can keep the property editor window open as a reference, gesture palette, and test screen.
On the property editor window (entitled "Select Gestures") you can:
- Select the gestures you want to include in your application and assign an action to each gesture.
- Access the Custom Gestures dialog box, which allows you to manage and create custom gestures.
Assigning Actions to Gestures
You can add actions quickly to your gestures by adding either TActionList or TActionManager to your form. Then assign actions to each gesture by using the Gesturing property editor (Select Gestures) and the Object Inspector, or just the Object Inspector, as follows:
- In the Select Gestures dialog box, select a gesture that you want to use and then assign an action to the gesture by using the dropdown list in the Object Inspector.
- In the Object Inspector, select a gesture that you want to use (or find a gesture that you enabled in the Select Gestures dialog box). The dropdown list in the value column lists available actions, in particular New Standard Actions. Select an action from the list to be associated with the gesture.
Note: If you do not add TActionList or TActionManager to your form, you cannot choose from New Standard Actions, and you must write your own event handler for the OnGesture event.
Creating Custom Gestures
You can create your own custom gestures on the Custom Gesture Designer dialog box.
If a gesture that you draw on the Custom Gestures dialog box is too similar to any of the other gestures used in the application, a warning is displayed, and you can review the conflict. Conflicts with existing gestures can cause errors in your application. You can also adjust the sensitivity of the comparison between the custom gesture you are creating or viewing and the other gestures.
You can manage your custom gestures on the Custom Gestures dialog box. Buttons enable you to edit, delete, import, and export gestures. For more information, see Creating Custom Gestures.
Other Gesturing Components
- TGestureListView can be associated with a TGestureManager to display a list of the gestures in the gesture manager. Gestures can also be programatically added or removed to allow customization.
- TGesturePreview is the same preview control used in the IDE (by double-clicking a gesture in the Select Gestures dialog box) and displays an animation of how to perform the gesture.
- TGestureRecorder is a surface to draw a gesture and record it for use later. You can use this component to build applications that allow your customers to customize the gestures associated with certain actions.
See Also
- Using Gesturing in Your Applications
- Creating Custom Gestures
- Standard Gestures enumerated
- Custom Gestures dialog box
- Custom Gesture Designer dialog box
- GestureCtrls.TGestureListView
- GestureCtrls.TGesturePreview
- GestureCtrls.TGestureRecorder
- Video: RAD Studio 2010 Touch Gesture Capabilities
- Video: Delphi 2010, Using Touch Features and Gestures