Tuesday, September 15, 2009

Interactive Gestures 101

As promised at my CodeRage 4 session I will be blogging about Gestures and the Touch feature of Delphi 2010. So here is a quick set of steps to use interactive gestures. It will require a multi-touch system such as I described here (the mouse will not work here) and some context by watching my CodeRage 4 session from here.

1. File | New VCL Application
2. Drop a TPanel on your form (there is a known bug using interactive gestures on the form)
3. Select Panel1 and expand the Touch property
4. Check igoPanSinglerFingerHorizontal, and check igPan. I also like to turn off toPressandHold
5. Go to events and add the following code to the OnGesture event:


if EventInfo.GestureID = igiPan then
Caption := IntToStr(EventInfo.Location.X);

Now run the application and move your finger left and right on the panel.

Note: Interactive Gestures don't require a TGestureManage. Only Gestures require the Gesture Manager.

Update: Fixed the code and added links for touch hardware and my CodeRage 4 session.

6 comments:

Rozan NAS said...

1. I think you mean EventInfo.GestureID
2. How do I need to test this gesture. I tried every type of panning (mouse-down and drag), nothing happens (event is not triggered even)
I bit more explanation will be much more appreciated I think.
Best regards,
Rozan

Lex Li said...

"Interactive Gestures don't require a TGestureManage. Only Gestures require the Gesture Manager." I think it hurts my eyes.

Isn't interactive gestures part of gestures naturally? Then why break such a natural relationship?

In all, consider using more meaningful and logical terms in the future. Thanks, man.

Chris Bensen said...

Rozan,

Thanks, fixed the code and I also added more information. Are you running a multi-touch system?

Chris Bensen said...

Lex,

Have you watched my CodeRage 4 session on Touch or Seppy Bloom's CodeRage 4 session on Gestures? The context of Gestures/Interactive Gestures/Multi-Touch are explained and will probably make more sense after you watch those sessions.

Graham Horn said...

Wish I could get interactive gestures to work on my Surface Pro running Windows 8. I've tried everything. The OnGesture event never triggers unless I use the Gesture Manager, which is supposedly mutually exclusive to interactive gestures.

Chris Bensen said...

Graham,

That is the way it was originally designed. I don't know what has been done lately to it, sorry.

Post a Comment