XE5手势

在 OnGesture 事件中响应 sgLeft、sgRight 手势; 操作步骤:  1、加 TGestureManager 控件如窗体: GestureManager1;  2、设置窗体属性 Touch.GestureManager := GestureManager1;  3、添加窗体的 OnCreate 事件, 写: Touch.StandardGestures := [sgLeft, sgRight];  4、添加窗体的 OnGesture 事件, 写响应代码.  上面的步骤 3 的目的是指定准备要接受识别的动作, 这在设计时选定比较方便:


unit Unit1;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Gestures;

type
  TForm1 = class(TForm)
    GestureManager1: TGestureManager;
    procedure FormGesture(Sender: TObject; const EventInfo: TGestureEventInfo;
      var Handled: Boolean);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

procedure TForm1.FormCreate(Sender: TObject);
var
 t:TStandardGestures;
begin
t:=[TStandardGesture.sgLeft,TStandardGesture.sgRight];
Form1.Touch.StandardGestures:=t;
end;

procedure TForm1.FormGesture(Sender: TObject;
  const EventInfo: TGestureEventInfo; var Handled: Boolean);
begin
 case EventInfo.GestureID of
  sgiLeft : ShowMessage('Left');
  sgiRight : ShowMessage('Right');
 end;
end;

end.

你可能感兴趣的:(XE5手势)