You can use event handlers in the script. Unlike the Delphi event
handler, script event handlers are not the methods of the object.
The following example shows how to connect an event handler to the
TButton.OnClick event:
var
b: TButton;
Form1: TForm;
procedure ButtonClick(Sender: TButton);
begin
ShowMessage(Sender.Name);
end;
begin
b := TButton.Create(Form1);
b.Parent := Form1;
b.OnClick := @ButtonClick; // same as b.OnClick := 'ButtonClick'
b.OnClick := nil; // clear the event
end.