[Lazarus] TControl.Click?
Hans-Peter Diettrich
DrDiettrich1 at aol.com
Sat Oct 1 18:42:39 CEST 2011
Martin schrieb:
> further more:
>
> ActionLink.Execute is virtual
>
> So comparing with the OnExecute method pointer is at the very least
> insufficient.
>
> If ActionLink.Execute is overridden, it could call/do anything.
>
> I would suggest to drop that check entirely
Delphi compares
DelegatesEqual(@FClient.OnClick, @Action.OnExecute)));
what looks good, except that DelegatesEqual accepts two Pointers - what
causes the well known comparison problems.
At least FOnClick is preferred over Execute:
procedure TControl.Click;
begin
{ Call OnClick if assigned and not equal to associated action's
OnExecute.
If associated action's OnExecute assigned then call it, otherwise, call
OnClick. }
if Assigned(FOnClick) and (Action <> nil) and not
DelegatesEqual(@FOnClick, @Action.OnExecute) then
FOnClick(Self)
else if not (csDesigning in ComponentState) and (ActionLink <> nil) then
ActionLink.Execute(Self)
else if Assigned(FOnClick) then
FOnClick(Self);
end;
DoDi
More information about the Lazarus
mailing list