1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| 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.Layouts,
FMX.StdCtrls;
type
TForm1 = class(TForm)
Layout1: TLayout;
Button1: TButton;
TimerLongTouch: TTimer;
procedure Button1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
procedure Button1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
procedure TimerLongTouchTimer(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
nDuration : Cardinal;
const
cLongTime = 3;
implementation
{$R *.fmx}
procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
begin
nDuration := 1;
TimerLongTouch.Enabled := True;
end;
procedure TForm1.Button1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
begin
if nDuration < cLongTime then begin
TimerLongTouch.Enabled := False;
nDuration := 1;
end;
end;
procedure TForm1.TimerLongTouchTimer(Sender: TObject);
begin
nDuration := nDuration +1;
if (nDuration = cLongTime) then begin
TimerLongTouch.Enabled := False;
ShowMessage('Long touch !');
end;
end;
end. |
Partager