i have a menu item, and i'm trying to assign its OnClick
event handler:
miFrobGizmo.OnClick := {something};
The OnClick
event handler property, like almost every other event handler, is defined as a TNotifyEvent
method type:
property OnClick: TNotifyEvent
where TNotifyEvent
is:
TNotifyEvent = procedure(Sender: TObject) of object;
i have an object, with a method matching the TNotifyEvent
signature:
TAnimal = class(TObject)
public
procedure Frob(Sender: TObject);
end;
So i think i should be able to take the method of the object and assign it to the click event handler:
var
Animal: TAnimal;
miFrobGizmo.OnClick := Animal.Frob;
Except i get the error:
[Error]File.pas(1234): Not enough actual parameters
Perhaps i'm having a brain fart, but i thought i should be able to do this.
A detail i failed to mention is that my object that has the matching method is having the method exposed though an interface:
IAnimal = interface
procedure Frob(Sender: TObject);
end;
TAnimal = class(TInterfacedObject, IAnimal)
public
procedure Frob(Sender: TObject);
end;
var
Animal: IAnimal;
miFrobGizmo.OnClick := Animal.Frob;