mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-07 01:46:05 +02:00
LCL: setting Action.OnExecute no longer changes the TMenuItem.OnClick
git-svn-id: trunk@41416 -
This commit is contained in:
parent
66a30a311c
commit
9a518d7730
@ -2693,13 +2693,24 @@ end;
|
|||||||
TControl Click
|
TControl Click
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TControl.Click;
|
procedure TControl.Click;
|
||||||
|
|
||||||
|
function OnClickIsActionExecute: boolean;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
if Action=nil then exit;
|
||||||
|
if not Assigned(Action.OnExecute) then exit;
|
||||||
|
if not Assigned(FOnClick) then exit;
|
||||||
|
Result:=CompareMethods(TMethod(FOnClick),TMethod(Action.OnExecute));
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//DebugLn(['TControl.Click ',DbgSName(Self)]);
|
//DebugLn(['TControl.Click ',DbgSName(Self)]);
|
||||||
// first call our own OnClick
|
// first call our own OnClick
|
||||||
if Assigned(FOnClick) then
|
if Assigned(FOnClick) then
|
||||||
FOnClick(Self);
|
FOnClick(Self);
|
||||||
// then trigger the Action
|
// then trigger the Action
|
||||||
if (not (csDesigning in ComponentState)) and (ActionLink <> nil) then
|
if (not (csDesigning in ComponentState)) and (ActionLink <> nil)
|
||||||
|
and (not OnClickIsActionExecute) then
|
||||||
ActionLink.Execute(Self);
|
ActionLink.Execute(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -58,8 +58,7 @@ end;
|
|||||||
|
|
||||||
function TControlActionLink.IsOnExecuteLinked: Boolean;
|
function TControlActionLink.IsOnExecuteLinked: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := inherited IsOnExecuteLinked
|
Result := inherited IsOnExecuteLinked;
|
||||||
and CompareMethods(TMethod(FClient.OnClick),TMethod(Action.OnExecute));
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TControlActionLink.SetCaption(const Value: string);
|
procedure TControlActionLink.SetCaption(const Value: string);
|
||||||
|
@ -76,8 +76,7 @@ end;
|
|||||||
|
|
||||||
function TMenuActionLink.IsOnExecuteLinked: Boolean;
|
function TMenuActionLink.IsOnExecuteLinked: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := inherited IsOnExecuteLinked
|
Result := inherited IsOnExecuteLinked;
|
||||||
and CompareMethods(TMethod(FClient.OnClick),TMethod(Action.OnExecute));
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMenuActionLink.SetAutoCheck(Value: Boolean);
|
procedure TMenuActionLink.SetAutoCheck(Value: Boolean);
|
||||||
@ -127,7 +126,8 @@ end;
|
|||||||
|
|
||||||
procedure TMenuActionLink.SetOnExecute(Value: TNotifyEvent);
|
procedure TMenuActionLink.SetOnExecute(Value: TNotifyEvent);
|
||||||
begin
|
begin
|
||||||
if IsOnExecuteLinked then FClient.OnClick := Value;
|
// Note: formerly this changed FClient.OnClick, but that is unneeded, because
|
||||||
|
// TMenuItem.Click executes Action
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,13 +50,24 @@ end;
|
|||||||
Call hooks and actions.
|
Call hooks and actions.
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TMenuItem.Click;
|
procedure TMenuItem.Click;
|
||||||
|
|
||||||
|
function OnClickIsActionExecute: boolean;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
if Action=nil then exit;
|
||||||
|
if not Assigned(Action.OnExecute) then exit;
|
||||||
|
if not Assigned(FOnClick) then exit;
|
||||||
|
Result:=CompareMethods(TMethod(FOnClick),TMethod(Action.OnExecute));
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if Enabled then
|
if Enabled then
|
||||||
begin
|
begin
|
||||||
if Assigned(OnMenuPopupHandler) then OnMenuPopupHandler(Self);
|
if Assigned(OnMenuPopupHandler) then OnMenuPopupHandler(Self);
|
||||||
|
|
||||||
if (not Assigned(ActionLink) and AutoCheck) or (Assigned(ActionLink) and
|
if AutoCheck
|
||||||
not (ActionLink.IsAutoCheckLinked) and AutoCheck) then
|
and ((not Assigned(ActionLink))
|
||||||
|
or (Assigned(ActionLink) and not ActionLink.IsAutoCheckLinked)) then
|
||||||
begin
|
begin
|
||||||
// Break a little Delphi compatibility
|
// Break a little Delphi compatibility
|
||||||
// It makes no sense to uncheck a checked RadioItem (besides, GTK can't handle it)
|
// It makes no sense to uncheck a checked RadioItem (besides, GTK can't handle it)
|
||||||
@ -64,17 +75,13 @@ begin
|
|||||||
Checked := not Checked;
|
Checked := not Checked;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Call OnClick if assigned and not equal to associated action's OnExecute.
|
// first call our OnClick
|
||||||
If associated action's OnExecute assigned then call it, otherwise, call
|
|
||||||
OnClick. }
|
|
||||||
if Assigned(FOnClick) and (Action <> nil) and (FOnClick <> Action.OnExecute) then
|
|
||||||
FOnClick(Self)
|
|
||||||
else
|
|
||||||
if not (csDesigning in ComponentState) and (ActionLink <> nil) then
|
|
||||||
FActionLink.Execute(Self)
|
|
||||||
else
|
|
||||||
if Assigned(FOnClick) then
|
if Assigned(FOnClick) then
|
||||||
FOnClick(Self);
|
FOnClick(Self);
|
||||||
|
// then trigger the Action
|
||||||
|
if not (csDesigning in ComponentState) and (ActionLink <> nil)
|
||||||
|
and not OnClickIsActionExecute then
|
||||||
|
FActionLink.Execute(Self);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -388,8 +395,6 @@ begin
|
|||||||
ShortCut := NewAction.ShortCut;
|
ShortCut := NewAction.ShortCut;
|
||||||
if (not CheckDefaults) or (Visible = True) then
|
if (not CheckDefaults) or (Visible = True) then
|
||||||
Visible := NewAction.Visible;
|
Visible := NewAction.Visible;
|
||||||
if (not CheckDefaults) or not Assigned(OnClick) then
|
|
||||||
OnClick := NewAction.OnExecute;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -537,11 +542,6 @@ begin
|
|||||||
Result := (ActionLink = nil) or not FActionLink.IsImageIndexLinked;
|
Result := (ActionLink = nil) or not FActionLink.IsImageIndexLinked;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMenuItem.IsOnClickStored: Boolean;
|
|
||||||
begin
|
|
||||||
Result := (ActionLink = nil) or not FActionLink.IsOnExecuteLinked;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
function TMenuItem.IsShortCutStored: boolean;
|
function TMenuItem.IsShortCutStored: boolean;
|
||||||
|
|
||||||
@ -1497,7 +1497,6 @@ begin
|
|||||||
HelpContext := Self.HelpContext;
|
HelpContext := Self.HelpContext;
|
||||||
Hint := Self.Hint;
|
Hint := Self.Hint;
|
||||||
ImageIndex := Self.ImageIndex;
|
ImageIndex := Self.ImageIndex;
|
||||||
OnExecute := Self.OnClick;
|
|
||||||
Visible := Self.Visible;
|
Visible := Self.Visible;
|
||||||
end
|
end
|
||||||
end else
|
end else
|
||||||
|
@ -153,7 +153,6 @@ type
|
|||||||
function IsHelpContextStored: boolean;
|
function IsHelpContextStored: boolean;
|
||||||
function IsHintStored: Boolean;
|
function IsHintStored: Boolean;
|
||||||
function IsImageIndexStored: Boolean;
|
function IsImageIndexStored: Boolean;
|
||||||
function IsOnClickStored: Boolean;
|
|
||||||
function IsShortCutStored: boolean;
|
function IsShortCutStored: boolean;
|
||||||
function IsVisibleStored: boolean;
|
function IsVisibleStored: boolean;
|
||||||
procedure SetAutoCheck(const AValue: boolean);
|
procedure SetAutoCheck(const AValue: boolean);
|
||||||
@ -284,7 +283,7 @@ type
|
|||||||
property SubMenuImages: TCustomImageList read FSubMenuImages write SetSubMenuImages;
|
property SubMenuImages: TCustomImageList read FSubMenuImages write SetSubMenuImages;
|
||||||
property Visible: Boolean read FVisible write SetVisible
|
property Visible: Boolean read FVisible write SetVisible
|
||||||
stored IsVisibleStored default True;
|
stored IsVisibleStored default True;
|
||||||
property OnClick: TNotifyEvent read FOnClick write FOnClick stored IsOnClickStored;
|
property OnClick: TNotifyEvent read FOnClick write FOnClick;
|
||||||
end;
|
end;
|
||||||
TMenuItemClass = class of TMenuItem;
|
TMenuItemClass = class of TMenuItem;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user