i have a method:
procedure Frob(Sender: TObject);
that i want to call when i click a menu item.
The method comes to me though an interface:
animal: IAnimal;
IAnimal = interface
procedure Frob(Sender: TObject);
end;
The question revolves around what to assign to the OnClick
event handler of a menu item (i.e. control):
var
animal: IAnimal;
...
begin
...
menuItem := TMenuItem.Create(FileMenu)
menuItem.Caption := 'Click me!';
menuItem.OnClick := <-------- what to do
...
end;
The obvious choice, my first attempt, and the wrong answer is:
menuItem.OnClick := animal.Frob;
So how can i call a method when user clicks a control?