FMX.Controls.TPopup.OnAniTimer

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

property OnAniTimer: TNotifyEvent read FOnAniTimer write SetOnAniTimer;

C++

__property System::Classes::TNotifyEvent OnAniTimer = {read=FOnAniTimer, write=SetOnAniTimer};

Properties

Type Visibility Source Unit Parent
event public
FMX.Controls.pas
FMX.Controls.hpp
FMX.Controls TPopup

Description

Periodically occurs during TCustomPopupForm custom animation execution.

The OnAniTimer event periodically occurs during AniDuration time while a custom animation executes during appearing and closing of the current TPopup pop-up window.

Write an OnAniTimer event handler to provide animation functionality during appearing and closing of the current pop-up window. AniDuration defines the animation duration in seconds.

To show a TPopup window you can set the IsOpen property to True or call the Popup method. Rendering the TPopup window, the owner form calls CreatePopupForm to create an instance of a TCustomPopupForm pop-up form stored in the PopupForm property. Notice that all visual components placed in the TPopup window are contained in the ContentControl created in the PopupForm pop-up form.

The OnAniTimer event handler has the type TNotifyEvent declared as follows:

 TNotifyEvent = procedure(Sender: TObject) of object;

Therefore, the Sender parameter, in the following example, can be cast to TCustomPopupForm. See how this is used in the AniTimeProc event handler of the OnAniTimer event in the following example implementing animation of appearing and closing of the TPopup window:

type
  TForm1 = class(TForm)
    Button1: TButton;
    Popup1: TPopup;
    Button2: TButton;
    Rectangle1: TRectangle;
    procedure FormCreate(Sender: TObject);
  public
    T: TDateTime;
    procedure AniTimeProc(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

procedure TForm1.AniTimeProc(Sender: TObject);
begin
  Button1.Text := FloatToStr(RoundTo((Now - T) * 86400{SecPerDay}, -2));
  TCustomPopupForm(Sender).ContentControl.Opacity := TCustomPopupForm(Sender).AniPosition;
  TCustomPopupForm(Sender).Left := Self.Left + Round(100 * TCustomPopupForm(Sender).AniPosition);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  T := Now;
  Popup1.Popup;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Popup1.AniDuration := 4;
  Popup1.OnAniTimer := AniTimeProc;
end;

end.

Notice that OnAniTimer can use AniPosition and other properties of TCustomPopupForm.

See Also