Here we go again… This week we’ll discuss a bit the new things in VCL with a special focus on the RAD Studio 2010’s natural input capabilities. (Gestures and Touch) overview. Mind you that we’re talking about a prerelease beta. Anything can change till release. Also, let us not forget to thank Embarcadero for giving us the permission to talk about this.
With the new engine you can choose different predefined movements of your pointing device (or create new, custom ones) in order to assign them different actions. The ones who use the Opera web browser (but not only) will find this familiar. For the others, let us remind that Windows (and hence Delphi) had a very old gesture already: Drag & Drop. Think at the new engine like something much more powerful. Of course, something which will be very used in pen computing, kiosk applications featuring (multi-)touch screens etc.
Before going in to details, let’s make something clear: Delphi tries to use the touch engine of yet-to-be-released Windows 7. If it cannot (because eg. the application is run on Windows XP), it uses it’s own recognition engine. How it does this? By using a language enhancement ( – subject of another post, of course ;-) ).
But now let’s start to analyze the new Delphi’s gesture engine…
Let’s have a look at the ‘Gestures’ category (pictured on the right). (No, don’t pay attention now at the two categories above: Ribbon Controls and Touch) Even if, as we said, we have predefined gestures, we can create new, custom ones. And exactly this is the main job of
TGestureManager. It can have more custom gestures per component (somewhat like
TActionManager) and it can persist these custom gestures in a file.
Of course for actually managing our gestures we have a Custom Gestures Editor. Here it is:
As you can see the Editor features assigning custom names to each gesture, sensitivity control, individual control to any gesture point (add / edit / delete) as well as zooming in and out, playing a simulation of gesture, recording a new one as well as testing the gesture with your pointing device (usually mouse). A very interesting thing is that it tells you if you have similarities with other gestures (including with built-in ones) and in which percentage. Incidentally, the triangle which I drawn is “100% similar” with the
sgiTriange built-in gesture (Standard in Delphi terminology). Because is so similar, I deleted it and I recorded a new gesture, called ‘Untitled’ (I’m so lazy sometimes…) and having the shape of the letter Z.
Well, let’s see how can we use the gestures. On the right is a part of the new property
Touch: TTouchManager; as it appears in the Object Inspector. Of course this new property is almost ‘everywhere’ in the VCL, being declared in
TControl. You can see in the
Touch.Gestures.Custom my own gesture, in the shape of the letter ‘Z’. In the ‘Standard’ branch there are the built-in gestures (or Standard) as I said. These are the most common ones which are provided by default. Any component “has” them. But in order to appear you must assign a
TGestureManager which, in fact, drags with it the Unit in which these Standard Gestures live.
As you can see, a certain control can respond to many gestures (hence the check-boxes next to each item).
You will actually use them by checking them in the Object Inspector and writing your own code for OnGesture event handler. The parameters of the OnGesture event are:
- Sender: TObject (gee…)
- const EventInfo: TGestureEventInfo;
- var Handled: Boolean;
…Of course, the 2nd parameter caries all the info which we want.
Also, you can remark that multi-touch tablets and screens are supported. See the options in the lower part of the image.
Also, there are other components in the ‘Gestures’ category:
TGestureListView is a
TCustomListView descendant which displays the name of gestures featuring a small thumbnail with the gesture’s shape for easy recognition. Very handy sometimes.
TGesturePreview is exactly what it says: a control which can display an animation with the shape of the assigned gesture. As an aside, you have here enough properties to customize the look of this control. And of course,
TGestureRecord is a simple panel which can ‘grab’ the gesture drawn on it.
As an aside, in the Touch category there is a
TTouchKeyboard component which is an on-screen keyboard component, common in kiosk / surface applications. A nice feature is the
Layout property with which you can have also a NumPad keyboard:
In this post we had an overview of the natural input capabilities of the RAD Studio 2010. This wasn’t intended to be an exhaustive introduction, neither a help replacement. It was intended to give you a small idea about what the thing is about. Btw, can you share with us your idea ?