mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-03 19:38:16 +02:00
reduced focus handling and improved focus setting
git-svn-id: trunk@3958 -
This commit is contained in:
parent
c184ecd39a
commit
1b47078742
@ -285,7 +285,7 @@ type
|
|||||||
function IsForm : Boolean;
|
function IsForm : Boolean;
|
||||||
procedure IconChanged(Sender: TObject);
|
procedure IconChanged(Sender: TObject);
|
||||||
function IsIconStored: Boolean;
|
function IsIconStored: Boolean;
|
||||||
{ events }
|
private
|
||||||
procedure WMActivate(var Message : TLMActivate); message LM_ACTIVATE;
|
procedure WMActivate(var Message : TLMActivate); message LM_ACTIVATE;
|
||||||
procedure WMDeactivate(var Message : TLMActivate); message LM_DEACTIVATE;
|
procedure WMDeactivate(var Message : TLMActivate); message LM_DEACTIVATE;
|
||||||
procedure WMPaint(var message: TLMPaint); message LM_PAINT;
|
procedure WMPaint(var message: TLMPaint); message LM_PAINT;
|
||||||
@ -466,6 +466,7 @@ type
|
|||||||
FCursorCount: integer;
|
FCursorCount: integer;
|
||||||
FCursorList: PCursorRec;
|
FCursorList: PCursorRec;
|
||||||
FCustomForms: TList;
|
FCustomForms: TList;
|
||||||
|
FCustomFormsZOrdered: TList;
|
||||||
FDefaultCursor: HCURSOR;
|
FDefaultCursor: HCURSOR;
|
||||||
FFocusedForm: TCustomForm;
|
FFocusedForm: TCustomForm;
|
||||||
FFonts : TStrings;
|
FFonts : TStrings;
|
||||||
@ -483,6 +484,7 @@ type
|
|||||||
function GetCursors(Index: Integer): HCURSOR;
|
function GetCursors(Index: Integer): HCURSOR;
|
||||||
function GetCustomFormCount: Integer;
|
function GetCustomFormCount: Integer;
|
||||||
function GetCustomForms(Index: Integer): TCustomForm;
|
function GetCustomForms(Index: Integer): TCustomForm;
|
||||||
|
function GetCustomFormsZOrdered(Index: Integer): TCustomForm;
|
||||||
function GetFonts : TStrings;
|
function GetFonts : TStrings;
|
||||||
function GetFormCount: Integer;
|
function GetFormCount: Integer;
|
||||||
function GetForms(IIndex: Integer): TForm;
|
function GetForms(IIndex: Integer): TForm;
|
||||||
@ -498,6 +500,7 @@ type
|
|||||||
destructor Destroy; Override;
|
destructor Destroy; Override;
|
||||||
function CustomFormIndex(AForm: TCustomForm): integer;
|
function CustomFormIndex(AForm: TCustomForm): integer;
|
||||||
function FormIndex(AForm: TForm): integer;
|
function FormIndex(AForm: TForm): integer;
|
||||||
|
function CustomFormZIndex(AForm: TCustomForm): integer;
|
||||||
public
|
public
|
||||||
property ActiveControl: TWinControl read FActiveControl;
|
property ActiveControl: TWinControl read FActiveControl;
|
||||||
property ActiveCustomForm: TCustomForm read FActiveCustomForm;
|
property ActiveCustomForm: TCustomForm read FActiveCustomForm;
|
||||||
@ -506,6 +509,7 @@ type
|
|||||||
property Cursors[Index: Integer]: HCURSOR read GetCursors write SetCursors;
|
property Cursors[Index: Integer]: HCURSOR read GetCursors write SetCursors;
|
||||||
property CustomFormCount: Integer read GetCustomFormCount;
|
property CustomFormCount: Integer read GetCustomFormCount;
|
||||||
property CustomForms[Index: Integer]: TCustomForm read GetCustomForms;
|
property CustomForms[Index: Integer]: TCustomForm read GetCustomForms;
|
||||||
|
property CustomFormsZOrdered[Index: Integer]: TCustomForm read GetCustomFormsZOrdered;
|
||||||
property FormCount: Integer read GetFormCount;
|
property FormCount: Integer read GetFormCount;
|
||||||
property Forms[Index: Integer]: TForm read GetForms;
|
property Forms[Index: Integer]: TForm read GetForms;
|
||||||
property Fonts : TStrings read GetFonts;
|
property Fonts : TStrings read GetFonts;
|
||||||
|
@ -229,13 +229,29 @@ end;
|
|||||||
Method: TCustomForm.SetFocus
|
Method: TCustomForm.SetFocus
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
Procedure TCustomForm.SetFocus;
|
Procedure TCustomForm.SetFocus;
|
||||||
|
|
||||||
|
procedure RaiseCannotFocus;
|
||||||
|
var
|
||||||
|
s: String;
|
||||||
|
begin
|
||||||
|
s:='[TCustomForm.SetFocus] '+Name+':'+ClassName+' '+rsCanNotFocus;
|
||||||
|
{$IFDEF VerboseFocus}
|
||||||
|
RaiseGDBException(s);
|
||||||
|
{$ELSE}
|
||||||
|
raise EInvalidOperation.Create(s);
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
Begin
|
Begin
|
||||||
{$IFDEF VerboseFocus}
|
{$IFDEF VerboseFocus}
|
||||||
writeln('TCustomForm.SetFocus ',Name,':',ClassName);
|
writeln('TCustomForm.SetFocus ',Name,':',ClassName);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
if not (Visible and Enabled and HandleAllocated) then Exit;
|
if not FActive then
|
||||||
if HandleAllocated then
|
begin
|
||||||
CNSendMessage(LM_SETFOCUS,Self,nil);
|
if not (Visible and Enabled) then
|
||||||
|
RaiseCannotFocus;
|
||||||
|
SetWindowFocus;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -338,13 +354,6 @@ begin
|
|||||||
if (FormStyle <> fsMDIForm) or (csDesigning in ComponentState) then
|
if (FormStyle <> fsMDIForm) or (csDesigning in ComponentState) then
|
||||||
SetActive(Message.Active {<> WA_INACTIVE});
|
SetActive(Message.Active {<> WA_INACTIVE});
|
||||||
FActive:=true;
|
FActive:=true;
|
||||||
if (FActiveControl<>nil) and FActiveControl.HandleAllocated
|
|
||||||
and (FActiveControl.Visible) and (FActiveControl.Enabled) then begin
|
|
||||||
{$IFDEF VerboseFocus}
|
|
||||||
writeln('TCustomForm.WMActivate B ',FActiveControl.Name,':',FActiveControl.ClassName);
|
|
||||||
{$ENDIF}
|
|
||||||
LCLLinux.SetFocus(FActiveControl.Handle);
|
|
||||||
end;
|
|
||||||
Activate;
|
Activate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -667,7 +676,7 @@ begin
|
|||||||
LM_ACTIVATE, LM_SETFOCUS, LM_KILLFOCUS:
|
LM_ACTIVATE, LM_SETFOCUS, LM_KILLFOCUS:
|
||||||
begin
|
begin
|
||||||
if not FocusMessages then Exit;
|
if not FocusMessages then Exit;
|
||||||
if (MSg = LM_SetFocus) and not (csDesigning in ComponentState)
|
if (Msg = LM_SetFocus) and not (csDesigning in ComponentState)
|
||||||
then begin
|
then begin
|
||||||
FocusHandle := 0;
|
FocusHandle := 0;
|
||||||
if FormStyle = fsMDIFORM
|
if FormStyle = fsMDIFORM
|
||||||
@ -682,7 +691,9 @@ begin
|
|||||||
TheMessage.Result:=0;
|
TheMessage.Result:=0;
|
||||||
if FocusHandle <> 0
|
if FocusHandle <> 0
|
||||||
then begin
|
then begin
|
||||||
//writeln('[TCustomForm.WndPRoc] A ',FActiveControl.ClassName);
|
{$IFDEF VerboseFocus}
|
||||||
|
writeln('[TCustomForm.WndProc] ',Name,':',ClassName);
|
||||||
|
{$ENDIF}
|
||||||
LCLLinux.SetFocus(FocusHandle);
|
LCLLinux.SetFocus(FocusHandle);
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
@ -865,14 +876,18 @@ Begin
|
|||||||
then
|
then
|
||||||
RaiseGDBException(SCannotFocus);
|
RaiseGDBException(SCannotFocus);
|
||||||
// EInvalidOperation.Create(SCannotFocus);
|
// EInvalidOperation.Create(SCannotFocus);
|
||||||
FActiveControl := AWinControl;
|
|
||||||
{$IFDEF VerboseFocus}
|
{$IFDEF VerboseFocus}
|
||||||
write('TCustomForm.SetActiveControl ',Name,':',ClassName,' FActive=',FActive);
|
write('TCustomForm.SetActiveControl ',Name,':',ClassName,' FActive=',FActive);
|
||||||
if FActiveControl<>nil then
|
if FActiveControl<>nil then
|
||||||
writeln(' FActiveControl=',FActiveControl.Name,':',FActiveControl.ClassName)
|
writeln(' OldActiveControl=',FActiveControl.Name,':',FActiveControl.ClassName)
|
||||||
else
|
else
|
||||||
writeln(' FActiveControl=nil');
|
writeln(' OldActiveControl=nil');
|
||||||
|
if AWinControl<>nil then
|
||||||
|
writeln(' NewActiveControl=',AWinControl.Name,':',AWinControl.ClassName)
|
||||||
|
else
|
||||||
|
writeln(' NewActiveControl=nil');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
FActiveControl := AWinControl;
|
||||||
if not (csLoading in ComponentState) then
|
if not (csLoading in ComponentState) then
|
||||||
begin
|
begin
|
||||||
if FActive then SetWindowFocus;
|
if FActive then SetWindowFocus;
|
||||||
@ -1115,6 +1130,8 @@ begin
|
|||||||
writeln();
|
writeln();
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
Result:=true;
|
||||||
|
|
||||||
{
|
{
|
||||||
Inc(FocusCount);
|
Inc(FocusCount);
|
||||||
|
|
||||||
@ -1374,6 +1391,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.92 2003/03/25 10:45:40 mattias
|
||||||
|
reduced focus handling and improved focus setting
|
||||||
|
|
||||||
Revision 1.91 2003/03/18 13:04:25 mattias
|
Revision 1.91 2003/03/18 13:04:25 mattias
|
||||||
improved focus debugging output
|
improved focus debugging output
|
||||||
|
|
||||||
|
@ -106,12 +106,10 @@ begin
|
|||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
until false;
|
until false;
|
||||||
if NewFocusControl.HandleAllocated then begin
|
ActiveControl:=NewFocusControl;
|
||||||
LCLLinux.SetFocus(NewFocusControl.Handle);
|
|
||||||
Key:=VK_UNKNOWN;
|
Key:=VK_UNKNOWN;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{** Return the localized or not title of dialog}
|
{** Return the localized or not title of dialog}
|
||||||
@ -341,7 +339,7 @@ begin
|
|||||||
|
|
||||||
for i:=0 to ComponentCount-1 do begin
|
for i:=0 to ComponentCount-1 do begin
|
||||||
if (Components[i] is TBitBtn) and (TBitBtn(Components[i]).Default) then begin
|
if (Components[i] is TBitBtn) and (TBitBtn(Components[i]).Default) then begin
|
||||||
TBitBtn(Components[i]).SetFocus;
|
ActiveControl:=TBitBtn(Components[i]);
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -381,6 +379,9 @@ end;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.4 2003/03/25 10:45:41 mattias
|
||||||
|
reduced focus handling and improved focus setting
|
||||||
|
|
||||||
Revision 1.3 2003/03/04 09:21:09 mattias
|
Revision 1.3 2003/03/04 09:21:09 mattias
|
||||||
added localization for env options from Olivier
|
added localization for env options from Olivier
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ begin
|
|||||||
FFonts := TStringlist.Create;
|
FFonts := TStringlist.Create;
|
||||||
TStringlist(FFonts).Sorted := True;
|
TStringlist(FFonts).Sorted := True;
|
||||||
FCustomForms:=TList.Create;
|
FCustomForms:=TList.Create;
|
||||||
|
FCustomFormsZOrdered:=TList.Create;
|
||||||
FFormList := TList.Create;
|
FFormList := TList.Create;
|
||||||
FPixelsPerInch:= ScreenInfo.PixelsPerInchX;
|
FPixelsPerInch:= ScreenInfo.PixelsPerInchX;
|
||||||
FHintFont := TFont.Create;
|
FHintFont := TFont.Create;
|
||||||
@ -54,6 +55,7 @@ begin
|
|||||||
FreeThenNil(FHintFont);
|
FreeThenNil(FHintFont);
|
||||||
FreeThenNil(FFormList);
|
FreeThenNil(FFormList);
|
||||||
FreeThenNil(FCustomForms);
|
FreeThenNil(FCustomForms);
|
||||||
|
FreeThenNil(FCustomFormsZOrdered);
|
||||||
FreeThenNil(FSaveFocusedList);
|
FreeThenNil(FSaveFocusedList);
|
||||||
FreeThenNil(FFonts);
|
FreeThenNil(FFonts);
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
@ -77,6 +79,15 @@ begin
|
|||||||
while (Result>=0) and (Forms[Result]<>AForm) do dec(Result);
|
while (Result>=0) and (Forms[Result]<>AForm) do dec(Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
function TScreen.CustomFormZIndex(AForm: TCustomForm): integer;
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
function TScreen.CustomFormZIndex(AForm: TCustomForm): integer;
|
||||||
|
begin
|
||||||
|
Result:=FCustomFormsZOrdered.Count-1;
|
||||||
|
while (Result>=0) and (CustomFormsZOrdered[Result]<>AForm) do dec(Result);
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
function TScreen.GetFonts : TStrings;
|
function TScreen.GetFonts : TStrings;
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
@ -173,6 +184,14 @@ begin
|
|||||||
Result := TCustomForm(FCustomForms[Index]);
|
Result := TCustomForm(FCustomForms[Index]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
function TScreen.GetCustomFormsZOrdered(Index: Integer): TCustomForm;
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
function TScreen.GetCustomFormsZOrdered(Index: Integer): TCustomForm;
|
||||||
|
begin
|
||||||
|
Result := TCustomForm(FCustomFormsZOrdered[Index]);
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Function: TScreen.AddForm
|
Function: TScreen.AddForm
|
||||||
Params: FForm: The form to be added
|
Params: FForm: The form to be added
|
||||||
@ -183,6 +202,7 @@ end;
|
|||||||
procedure TScreen.AddForm(AForm: TCustomForm);
|
procedure TScreen.AddForm(AForm: TCustomForm);
|
||||||
begin
|
begin
|
||||||
FCustomForms.Add(AForm);
|
FCustomForms.Add(AForm);
|
||||||
|
FCustomFormsZOrdered.Add(AForm);
|
||||||
if AForm is TForm then
|
if AForm is TForm then
|
||||||
begin
|
begin
|
||||||
FFormList.Add(AForm);
|
FFormList.Add(AForm);
|
||||||
@ -249,6 +269,7 @@ end;
|
|||||||
procedure TScreen.RemoveForm(AForm: TCustomForm);
|
procedure TScreen.RemoveForm(AForm: TCustomForm);
|
||||||
begin
|
begin
|
||||||
FCustomForms.Remove(AForm);
|
FCustomForms.Remove(AForm);
|
||||||
|
FCustomFormsZOrdered.Remove(AForm);
|
||||||
FFormList.Remove(AForm);
|
FFormList.Remove(AForm);
|
||||||
Application.UpdateVisible;
|
Application.UpdateVisible;
|
||||||
//if (FCustomForms.Count = 0) and (Application.FHintWindow <> nil) then
|
//if (FCustomForms.Count = 0) and (Application.FHintWindow <> nil) then
|
||||||
|
@ -168,6 +168,7 @@ ResourceString
|
|||||||
rsUnsupportedBitmapFormat = 'Unsupported bitmap format.';
|
rsUnsupportedBitmapFormat = 'Unsupported bitmap format.';
|
||||||
rsNoInterfaceObject = 'No interface object. '
|
rsNoInterfaceObject = 'No interface object. '
|
||||||
+'Plz check if the unit "interfaces" was added to the programs uses clause.';
|
+'Plz check if the unit "interfaces" was added to the programs uses clause.';
|
||||||
|
rsCanNotFocus = 'Can not focus';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user