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;

This IMO will invoke ActionLink.Execute if (a different) FOnClick is assigned - so far okay. But FOnClick will *not* be invoked then (even if different), and it will be invoked *always* in design state.

Is it really okay to invoke an user-supplied OnClick handler in design state?


What about something like this:

  if (csDesigning in ComponentState) then
    exit; //nothing called in design state
  if (ActionLink <> nil)
    and ((Action=nil) or (@FOnClick <> @Action.OnExecute) then
    ActionLink.Execute(Self); //only if different from FOnClick
  if Assigned(FOnClick) then //eventually also: if not handled?
    FOnClick(Self); //always if assigned
end;

I also wonder what's the difference or relationship between Action and ActionLink - can somebody explain? Does ActionLink (when assigned) take precedence over Action?

DoDi


--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to