mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-17 14:49:28 +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
|
||||
if FActiveControl <> AWinControl then
|
||||
begin
|
||||
if not
|
||||
((AWinControl = nil)
|
||||
or ((AWinControl <> Self)
|
||||
and (GetParentForm(AWinControl) = Self)
|
||||
and ((csLoading in ComponentState)
|
||||
or AWinControl.CanFocus)))
|
||||
then begin
|
||||
{$IFDEF VerboseFocus}
|
||||
RaiseGDBException(SCannotFocus);
|
||||
{$ELSE}
|
||||
EInvalidOperation.Create(SCannotFocus);
|
||||
{$ENDIF}
|
||||
if (AWinControl<>nil) then begin
|
||||
if (AWinControl=Self)
|
||||
or (GetParentForm(AWinControl)<>Self)
|
||||
or ((not (csLoading in ComponentState))
|
||||
and (not AWinControl.CanFocus))
|
||||
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}
|
||||
RaiseGDBException(SCannotFocus);
|
||||
{$ELSE}
|
||||
raise EInvalidOperation.Create(SCannotFocus);
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
{$IFDEF VerboseFocus}
|
||||
DbgOut('TCustomForm.SetActiveControl ',Name,':',ClassName,' FActive=',DbgS(FActive));
|
||||
@ -1339,7 +1340,7 @@ begin
|
||||
if fsModal in FFormState then
|
||||
ModalResult := mrCancel
|
||||
else begin
|
||||
DebugLn('TCustomForm.Close A ',DbgSName(Self));
|
||||
//DebugLn('TCustomForm.Close A ',DbgSName(Self));
|
||||
if CloseQuery then
|
||||
begin
|
||||
if FormStyle = fsMDIChild then begin
|
||||
@ -1350,10 +1351,10 @@ begin
|
||||
end else begin
|
||||
CloseAction := caHide;
|
||||
end;
|
||||
DebugLn('TCustomForm.Close B ',DbgSName(Self));
|
||||
//DebugLn('TCustomForm.Close B ',DbgSName(Self));
|
||||
DoClose(CloseAction);
|
||||
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
|
||||
else if CloseAction = caHide then Hide
|
||||
else if CloseAction = caMinimize then WindowState := wsMinimized
|
||||
|
@ -1555,9 +1555,11 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TWinControl CanFocus }
|
||||
{------------------------------------------------------------------------------}
|
||||
{------------------------------------------------------------------------------
|
||||
TWinControl CanFocus
|
||||
|
||||
|
||||
------------------------------------------------------------------------------}
|
||||
Function TWinControl.CanFocus : Boolean;
|
||||
var
|
||||
Control: TWinControl;
|
||||
@ -1570,8 +1572,9 @@ begin
|
||||
begin
|
||||
Control := Self;
|
||||
repeat
|
||||
if not (Control.IsControlVisible and Control.Enabled) then Exit;
|
||||
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;
|
||||
until false;
|
||||
Result := True;
|
||||
|
Loading…
Reference in New Issue
Block a user