mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 16:49:44 +02:00
LCL: TCustomForm.SetFocusedControl fixed COntrol=nil
git-svn-id: trunk@13132 -
This commit is contained in:
parent
d01719fc58
commit
50ebba2ee8
@ -888,9 +888,9 @@ begin
|
|||||||
if (FActiveControl = nil) and (Parent=nil) then begin
|
if (FActiveControl = nil) and (Parent=nil) then begin
|
||||||
// automatically choose a control to focus
|
// automatically choose a control to focus
|
||||||
SetFocusedControl(FindDefaultForActiveControl);
|
SetFocusedControl(FindDefaultForActiveControl);
|
||||||
{ $IFDEF VerboseFocus}
|
{$IFDEF VerboseFocus}
|
||||||
DebugLn('TCustomForm.WndProc Set FActiveControl := ',DbgSName(FActiveControl));
|
DebugLn('TCustomForm.WndProc Set FActiveControl := ',DbgSName(FActiveControl));
|
||||||
{ $ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if FormStyle = fsMDIFORM then
|
if FormStyle = fsMDIFORM then
|
||||||
@ -1625,7 +1625,8 @@ var
|
|||||||
CurControl: TWinControl;
|
CurControl: TWinControl;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
if (csDestroying in Control.ComponentState) then exit;
|
if (Control<>nil)
|
||||||
|
and (csDestroying in Control.ComponentState) then exit;
|
||||||
|
|
||||||
if (Parent<>nil) then begin
|
if (Parent<>nil) then begin
|
||||||
// delegate to topmost form
|
// delegate to topmost form
|
||||||
@ -1644,22 +1645,25 @@ begin
|
|||||||
|
|
||||||
// update Screen object
|
// update Screen object
|
||||||
Screen.FActiveControl := Control;
|
Screen.FActiveControl := Control;
|
||||||
Screen.FActiveCustomForm := Self;
|
if Control<>nil then begin
|
||||||
Screen.MoveFormToFocusFront(Self);
|
Screen.FActiveCustomForm := Self;
|
||||||
if Self is TForm then
|
Screen.MoveFormToFocusFront(Self);
|
||||||
Screen.FActiveForm := TForm(Self)
|
if Self is TForm then
|
||||||
else
|
Screen.FActiveForm := TForm(Self)
|
||||||
Screen.FActiveForm := nil;
|
else
|
||||||
|
Screen.FActiveForm := nil;
|
||||||
|
end;
|
||||||
|
|
||||||
{$IFDEF VerboseFocus}
|
{$IFDEF VerboseFocus}
|
||||||
DbgOut('TCustomForm.SetFocusedControl Self=',DbgSName(Self));
|
DbgOut('TCustomForm.SetFocusedControl Self=',DbgSName(Self));
|
||||||
DbgOut(' Control=',DbgSName(Control),' Control.HandleAllocated=',dbgs(Control.HandleAllocated));
|
if Control<>nil then
|
||||||
|
DbgOut(' Control=',DbgSName(Control),' Control.HandleAllocated=',dbgs(Control.HandleAllocated));
|
||||||
DebugLn();
|
DebugLn();
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
Result:=true;
|
Result:=true;
|
||||||
|
|
||||||
if not (csFocusing in Control.ControlState) then begin
|
if (Control<>nil) and (not (csFocusing in Control.ControlState)) then begin
|
||||||
// prevent looping
|
// prevent looping
|
||||||
Control.ControlState := Control.ControlState + [csFocusing];
|
Control.ControlState := Control.ControlState + [csFocusing];
|
||||||
try
|
try
|
||||||
|
Loading…
Reference in New Issue
Block a user