Creating real-time TEdit and OnEnter action

2

Lately I've been developing a mobile app, and I need to create a real-time%% with the predefined action function. So far I can create, but without the TEdit action function.

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 setting the OnEnter property?

    
asked by anonymous 27.10.2014 / 23:22

1 answer

2

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

So:

edit.OnEnter := executaOutraProcure;

This way the membership will be accepted. What you can not forget is that the method signature should be the same.

I write the method in an executable scope, such as a search, using the parentheses means that you are forcing it to execute.

In a VCL Forms Application , adding a TEdit to Form and creating by associating a method with the OnEnter event, it creates a signature like this: / p>

procedure Form1.Edit1Enter(Sender: TObject);

That is, your method needs to have this parameter Sender , of type TObject . Remember that it needs to be a class method, not just any procedure.

A little more information:

The OnEnter event is of type TEdit . TNotifyEvent is declared in one of the TNotifyEvent , TEdit and type is declared as:

type
  TNotifyEvent = procedure(Sender: TObject) of object;
    
27.10.2014 / 23:46