LCL: TMenuItem.Click: do not call OnClick if Action.OnExecute=OnClick, call Action.Execute always on click

git-svn-id: trunk@41683 -
This commit is contained in:
mattias 2013-06-11 22:30:58 +00:00
parent 4a1f602815
commit b63a49d5ea

View File

@ -60,6 +60,8 @@ procedure TMenuItem.Click;
Result:=CompareMethods(TMethod(FOnClick),TMethod(Action.OnExecute));
end;
var
CallAction: Boolean;
begin
if Enabled then
begin
@ -75,13 +77,14 @@ begin
Checked := not Checked;
end;
// first call our OnClick
if Assigned(FOnClick) then
CallAction:=(not (csDesigning in ComponentState)) and (ActionLink <> nil);
// first call our own OnClick if it differs from Action.OnExecute
if Assigned(FOnClick)
and ((not CallAction) or (not OnClickIsActionExecute)) then
FOnClick(Self);
// then trigger the Action
if not (csDesigning in ComponentState) and (ActionLink <> nil)
and not OnClickIsActionExecute then
FActionLink.Execute(Self);
if CallAction then
ActionLink.Execute(Self);
end;
end;