mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-12 15:28:36 +02:00
LCL: clear TCustomForm.FLastFocusedControl when it is destroyed
git-svn-id: trunk@25353 -
This commit is contained in:
parent
8f747ee3f3
commit
6ceab75bed
@ -473,6 +473,7 @@ type
|
|||||||
procedure SetPopupParent(const AValue: TCustomForm);
|
procedure SetPopupParent(const AValue: TCustomForm);
|
||||||
procedure SetPosition(Value : TPosition);
|
procedure SetPosition(Value : TPosition);
|
||||||
procedure SetShowInTaskbar(Value: TShowInTaskbar);
|
procedure SetShowInTaskbar(Value: TShowInTaskbar);
|
||||||
|
procedure SetLastFocusedControl(AControl: TWinControl);
|
||||||
procedure SetWindowFocus;
|
procedure SetWindowFocus;
|
||||||
procedure SetWindowState(Value : TWindowState);
|
procedure SetWindowState(Value : TWindowState);
|
||||||
procedure WMActivate(var Message : TLMActivate); message LM_ACTIVATE;
|
procedure WMActivate(var Message : TLMActivate); message LM_ACTIVATE;
|
||||||
|
@ -167,15 +167,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
opRemove:
|
opRemove:
|
||||||
begin
|
begin
|
||||||
if (FActionLists <> nil) and (AComponent is TCustomActionList) then
|
// first clean up references
|
||||||
DoRemoveActionList(TCustomActionList(AComponent))
|
|
||||||
else
|
|
||||||
if AComponent = Menu then
|
|
||||||
Menu := nil
|
|
||||||
else
|
|
||||||
if AComponent = PopupParent then
|
|
||||||
PopupParent := nil;
|
|
||||||
|
|
||||||
if FActiveControl=AComponent then
|
if FActiveControl=AComponent then
|
||||||
begin
|
begin
|
||||||
{$IFDEF VerboseFocus}
|
{$IFDEF VerboseFocus}
|
||||||
@ -187,6 +179,17 @@ begin
|
|||||||
FDefaultControl := nil;
|
FDefaultControl := nil;
|
||||||
if AComponent = FCancelControl then
|
if AComponent = FCancelControl then
|
||||||
FCancelControl := nil;
|
FCancelControl := nil;
|
||||||
|
if AComponent=FLastFocusedControl then
|
||||||
|
FLastFocusedControl:=nil;
|
||||||
|
// then do stuff which can trigger things
|
||||||
|
if (FActionLists <> nil) and (AComponent is TCustomActionList) then
|
||||||
|
DoRemoveActionList(TCustomActionList(AComponent))
|
||||||
|
else
|
||||||
|
if AComponent = Menu then
|
||||||
|
Menu := nil
|
||||||
|
else
|
||||||
|
if AComponent = PopupParent then
|
||||||
|
PopupParent := nil;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if FDesigner <> nil then
|
if FDesigner <> nil then
|
||||||
@ -1806,6 +1809,13 @@ begin
|
|||||||
UpdateShowInTaskBar;
|
UpdateShowInTaskBar;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomForm.SetLastFocusedControl(AControl: TWinControl);
|
||||||
|
begin
|
||||||
|
if FLastFocusedControl=AControl then exit;
|
||||||
|
FLastFocusedControl:=AControl;
|
||||||
|
FLastFocusedControl.FreeNotification(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
TCustomForm Constructor
|
TCustomForm Constructor
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
@ -2156,7 +2166,7 @@ function TCustomForm.SetFocusedControl(Control: TWinControl): Boolean;
|
|||||||
// calling of CM_EXIT can cause other focus changes - so FLastFocusedControl can change after the call
|
// calling of CM_EXIT can cause other focus changes - so FLastFocusedControl can change after the call
|
||||||
// therefore we need to change it before the call
|
// therefore we need to change it before the call
|
||||||
Tmp := FLastFocusedControl;
|
Tmp := FLastFocusedControl;
|
||||||
FLastFocusedControl := Tmp.Parent;
|
SetLastFocusedControl(Tmp.Parent);
|
||||||
Tmp.Perform(CM_EXIT, 0, 0);
|
Tmp.Perform(CM_EXIT, 0, 0);
|
||||||
if SaveFocusState <> LastState then
|
if SaveFocusState <> LastState then
|
||||||
Exit(False);
|
Exit(False);
|
||||||
@ -2164,7 +2174,8 @@ function TCustomForm.SetFocusedControl(Control: TWinControl): Boolean;
|
|||||||
|
|
||||||
while FLastFocusedControl <> Control do
|
while FLastFocusedControl <> Control do
|
||||||
begin
|
begin
|
||||||
FLastFocusedControl := NextChildControl(FLastFocusedControl, Control);
|
SetLastFocusedControl(NextChildControl(FLastFocusedControl, Control));
|
||||||
|
if FLastFocusedControl=nil then break;
|
||||||
LastState := SaveFocusState;
|
LastState := SaveFocusState;
|
||||||
FLastFocusedControl.Perform(CM_ENTER, 0, 0);
|
FLastFocusedControl.Perform(CM_ENTER, 0, 0);
|
||||||
if SaveFocusState <> LastState then
|
if SaveFocusState <> LastState then
|
||||||
|
Loading…
Reference in New Issue
Block a user