[Lazarus] TControl.Click?

Mattias Gaertner nc-gaertnma at netcologne.de
Sat Oct 1 10:05:07 CEST 2011


On Sat, 01 Oct 2011 08:39:42 +0100
Martin <lazarus at mfriebe.de> wrote:

> On 01/10/2011 07:53, Mattias Gaertner wrote:
> > On Sat, 01 Oct 2011 03:04:56 +0200
> > Hans-Peter Diettrich<DrDiettrich1 at aol.com>  wrote:
> >
> >> I don't understand the logic behind TControl.Click:
> >>
> >> procedure TControl.Click;
> >> begin
> >>     //DebugLn(['TControl.Click ',DbgSName(Self)]);
> >>     if (not (csDesigning in ComponentState)) and (ActionLink<>  nil) and
> >>        ((Action=nil) or (@FOnClick<>  @Action.OnExecute) or
> >> Assigned(FOnClick)) then
> >>       ActionLink.Execute(Self)
> >>     else
> >>     if Assigned(FOnClick) then
> >>       FOnClick(Self);
> >> end;
> >>
> >>
> 
> Maybe I overlook something, but
> @FOnClick is the address of the variable holding the method reference 
> (or nil)
> so is @Action.OnExecute
> 
> So when can they ever be equal?

You are right.

 
> Should that maybe compare FOnClick <> Action.OnExecute ?

That would miss difference in Data.
I added a CompareMem.

 
> Also is that supposed to be a shortcut, saving the call, or is that 
> indeed supposed to modify behaviour?

Good question. 
I guess it would be enough to check (not (csDesigning in
ComponentState)) and (ActionLink <> nil).

Maybe the Delphi docs have an answer.

> Even if the 2 callbacks are pointing to the same method, calling 
> Action.OnExecute, will call the callback with Sender=TheAction, while 
> FOnClick gets the current object.


Mattias




More information about the Lazarus mailing list