Creating Tedit in Real-Time and Onenter Action

Asked

Viewed 1,024 times

2

Lately I’m developing a mobile app and need to create a TEdit in real time with the predefined action function. So far I can create, but without the function OnEnter action.

Here is the code:

procedure CriarEdit;
var
  tipo:TForm;
  edit: TEdit;
begin
  tipo := Form1;
  edit := TEdit.Create(tipo);
  edit.Name := 'cp1';
  edit.Height := 30;
  edit.Width := 81.00001;
  edit.Enabled := true;
  edit.Visible := true;
  edit.ReadOnly := true;
  edit.Parent := tipo;
  edit.HitTest := true;
  // edit.OnEnter := executaOutraProcedure(); -- aqui dá problemas
end;

How can I be defining the Onenter property?

1 answer

2


I’m not familiar with mobile development yet, not even with Delphi. But the association of an event method has to be done without the parentheses.

Thus:

edit.OnEnter := executaOutraProcure;

This way the Association will be accepted.
What you must remember is that the signature of the method must be the same.

I write the method in an executable scope, like a search, using the parentheses means you are forcing the execution of it.

In a VCL Forms Application, adding a TEdit at the Form and creating a method associated with the event OnEnter, it creates a signature like this:

procedure Form1.Edit1Enter(Sender: TObject);

That is, your method needs to have this parameter o Sender, of the kind TObject.
Remembering that it needs to be a class method, and not just any process.


A little more information:

The event OnEnter of a TEdit is the type TNotifyEvent.
TNotifyEvent is declared in one of the acenstrais of TEdit, the TWinControl and the type is declared so:

type
  TNotifyEvent = procedure(Sender: TObject) of object;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.