Need to call onclick event when component is running mode

  

I have created a component using TPanel in Firemonkey. My idea is to click my component in run time and implement some functionality. So when I drag my component on the form and run application then I clicked on my component that time my function will work.

Here I created a Component, source code are as follows:

unit Layout1;

interface

uses
FMX.controls, System.Classes,FMX.StdCtrls, FMX.Types,System.UITypes, System.SysUtils,FMX.Dialogs;

type
TTestPnl = class(TPanel) // inherit panel
private
protected
public
Pnl : TPanel;
constructor Create(AOwner : TComponent); override;
procedure Click; override;
published

end;

procedure Register;

implementation

// Creation component at run time with assigning onclick event
constructor TTestPnl .Create(AOwner: TComponent);
begin
inherited;
Pnl := TPanel.Create(Self);
with Pnl do
begin
Height := 145.000000000000000000;
Position.X := 408.000000000000000000;
Position.Y := 40.000000000000000000;
Width := 201.000000000000000000;
TabOrder := 0;
OnClick := click;
end;

// Implementing Onclick functionality for runtime
procedure TTestPnl .Click;
begin
inherited;
ShowMessage(‘Click Event Call’);
end;

procedure Register;
begin
RegisterComponents(‘TestPnl’, [TTestPnl]);
end;

end.

In my code when I drag component that time only click event call. But I need after drag component run application that time I click my component that time my procedure will call.

Comments are closed.