mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 03:20:44 +02:00
fixed checking SetActiveControl
git-svn-id: trunk@8159 -
This commit is contained in:
parent
7960598843
commit
2074b79dab
@ -1149,18 +1149,19 @@ Procedure TCustomForm.SetActiveControl(AWinControl: TWinControl);
|
|||||||
Begin
|
Begin
|
||||||
if FActiveControl <> AWinControl then
|
if FActiveControl <> AWinControl then
|
||||||
begin
|
begin
|
||||||
if not
|
if (AWinControl<>nil) then begin
|
||||||
((AWinControl = nil)
|
if (AWinControl=Self)
|
||||||
or ((AWinControl <> Self)
|
or (GetParentForm(AWinControl)<>Self)
|
||||||
and (GetParentForm(AWinControl) = Self)
|
or ((not (csLoading in ComponentState))
|
||||||
and ((csLoading in ComponentState)
|
and (not AWinControl.CanFocus))
|
||||||
or AWinControl.CanFocus)))
|
then begin
|
||||||
then begin
|
DebugLn('TCustomForm.SetActiveControl ',DbgSName(Self),' AWinControl=',DbgSName(AWinControl),' GetParentForm(AWinControl)=',DbgSName(GetParentForm(AWinControl)),' csLoading=',dbgs(csLoading in ComponentState),' AWinControl.CanFocus=',dbgs((AWinControl<>nil) and AWinControl.CanFocus));
|
||||||
{$IFDEF VerboseFocus}
|
{$IFDEF VerboseFocus}
|
||||||
RaiseGDBException(SCannotFocus);
|
RaiseGDBException(SCannotFocus);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
EInvalidOperation.Create(SCannotFocus);
|
raise EInvalidOperation.Create(SCannotFocus);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
{$IFDEF VerboseFocus}
|
{$IFDEF VerboseFocus}
|
||||||
DbgOut('TCustomForm.SetActiveControl ',Name,':',ClassName,' FActive=',DbgS(FActive));
|
DbgOut('TCustomForm.SetActiveControl ',Name,':',ClassName,' FActive=',DbgS(FActive));
|
||||||
@ -1339,7 +1340,7 @@ begin
|
|||||||
if fsModal in FFormState then
|
if fsModal in FFormState then
|
||||||
ModalResult := mrCancel
|
ModalResult := mrCancel
|
||||||
else begin
|
else begin
|
||||||
DebugLn('TCustomForm.Close A ',DbgSName(Self));
|
//DebugLn('TCustomForm.Close A ',DbgSName(Self));
|
||||||
if CloseQuery then
|
if CloseQuery then
|
||||||
begin
|
begin
|
||||||
if FormStyle = fsMDIChild then begin
|
if FormStyle = fsMDIChild then begin
|
||||||
@ -1350,10 +1351,10 @@ begin
|
|||||||
end else begin
|
end else begin
|
||||||
CloseAction := caHide;
|
CloseAction := caHide;
|
||||||
end;
|
end;
|
||||||
DebugLn('TCustomForm.Close B ',DbgSName(Self));
|
//DebugLn('TCustomForm.Close B ',DbgSName(Self));
|
||||||
DoClose(CloseAction);
|
DoClose(CloseAction);
|
||||||
if CloseAction <> caNone then begin
|
if CloseAction <> caNone then begin
|
||||||
DebugLn('TCustomForm.Close C ',DbgSName(Self),' ',dbgs(ord(CloseAction)));
|
//DebugLn('TCustomForm.Close C ',DbgSName(Self),' ',dbgs(ord(CloseAction)));
|
||||||
if Application.MainForm = Self then Application.Terminate
|
if Application.MainForm = Self then Application.Terminate
|
||||||
else if CloseAction = caHide then Hide
|
else if CloseAction = caHide then Hide
|
||||||
else if CloseAction = caMinimize then WindowState := wsMinimized
|
else if CloseAction = caMinimize then WindowState := wsMinimized
|
||||||
|
@ -1555,9 +1555,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------}
|
{------------------------------------------------------------------------------
|
||||||
{ TWinControl CanFocus }
|
TWinControl CanFocus
|
||||||
{------------------------------------------------------------------------------}
|
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
Function TWinControl.CanFocus : Boolean;
|
Function TWinControl.CanFocus : Boolean;
|
||||||
var
|
var
|
||||||
Control: TWinControl;
|
Control: TWinControl;
|
||||||
@ -1570,8 +1572,9 @@ begin
|
|||||||
begin
|
begin
|
||||||
Control := Self;
|
Control := Self;
|
||||||
repeat
|
repeat
|
||||||
if not (Control.IsControlVisible and Control.Enabled) then Exit;
|
|
||||||
if Control = Form then break;
|
if Control = Form then break;
|
||||||
|
// test all except the Form if it is visible and enabled
|
||||||
|
if not (Control.IsControlVisible and Control.Enabled) then Exit;
|
||||||
Control := Control.Parent;
|
Control := Control.Parent;
|
||||||
until false;
|
until false;
|
||||||
Result := True;
|
Result := True;
|
||||||
|
Loading…
Reference in New Issue
Block a user