procedure TJbForm.MenuItem1Click(Sender: TObject);
begin
// Three different ways to write this, with subtly different
// ways to interpret it:
Button1Click(Sender);
// 1. "Call some other function. The name suggests it's the
// function that also handles button clicks."
Button1.OnClick(Sender);
// 2. "Call whatever method we call when the button gets clicked."
// (And hope the property isn't nil!)
Button1.Click;
// 3. "Pretend the button was clicked."
end;
procedure HandleClick;
begin
// Do something.
end;
procedure TJbForm.Button1Click(Sender: TObject);
begin
HandleClick;
end;
procedure TJbForm.MenuItem1Click(Sender: TObject);
begin
HandleClick;
end;
procedure TJbForm.Action1Click(Sender: TObject);
begin
// Do something
// (Depending on how closely this event's behavior is tied to
// manipulating the rest of the UI controls, it might make
// sense to keep the HandleClick function I mentioned above.)
end;