mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-28 12:45:21 +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;
|
||||
procedure IconChanged(Sender: TObject);
|
||||
function IsIconStored: Boolean;
|
||||
{ events }
|
||||
private
|
||||
procedure WMActivate(var Message : TLMActivate); message LM_ACTIVATE;
|
||||
procedure WMDeactivate(var Message : TLMActivate); message LM_DEACTIVATE;
|
||||
procedure WMPaint(var message: TLMPaint); message LM_PAINT;
|
||||
@ -466,6 +466,7 @@ type
|
||||
FCursorCount: integer;
|
||||
FCursorList: PCursorRec;
|
||||
FCustomForms: TList;
|
||||
FCustomFormsZOrdered: TList;
|
||||
FDefaultCursor: HCURSOR;
|
||||
FFocusedForm: TCustomForm;
|
||||
FFonts : TStrings;
|
||||
@ -483,6 +484,7 @@ type
|
||||
function GetCursors(Index: Integer): HCURSOR;
|
||||
function GetCustomFormCount: Integer;
|
||||
function GetCustomForms(Index: Integer): TCustomForm;
|
||||
function GetCustomFormsZOrdered(Index: Integer): TCustomForm;
|
||||
function GetFonts : TStrings;
|
||||
function GetFormCount: Integer;
|
||||
function GetForms(IIndex: Integer): TForm;
|
||||
@ -498,6 +500,7 @@ type
|
||||
destructor Destroy; Override;
|
||||
function CustomFormIndex(AForm: TCustomForm): integer;
|
||||
function FormIndex(AForm: TForm): integer;
|
||||
function CustomFormZIndex(AForm: TCustomForm): integer;
|
||||
public
|
||||
property ActiveControl: TWinControl read FActiveControl;
|
||||
property ActiveCustomForm: TCustomForm read FActiveCustomForm;
|
||||
@ -506,6 +509,7 @@ type
|
||||
property Cursors[Index: Integer]: HCURSOR read GetCursors write SetCursors;
|
||||
property CustomFormCount: Integer read GetCustomFormCount;
|
||||
property CustomForms[Index: Integer]: TCustomForm read GetCustomForms;
|
||||
property CustomFormsZOrdered[Index: Integer]: TCustomForm read GetCustomFormsZOrdered;
|
||||
property FormCount: Integer read GetFormCount;
|
||||
property Forms[Index: Integer]: TForm read GetForms;
|
||||
property Fonts : TStrings read GetFonts;
|
||||
|
@ -229,13 +229,29 @@ end;
|
||||
Method: 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
|
||||
{$IFDEF VerboseFocus}
|
||||
writeln('TCustomForm.SetFocus ',Name,':',ClassName);
|
||||
{$ENDIF}
|
||||
if not (Visible and Enabled and HandleAllocated) then Exit;
|
||||
if HandleAllocated then
|
||||
CNSendMessage(LM_SETFOCUS,Self,nil);
|
||||
if not FActive then
|
||||
begin
|
||||
if not (Visible and Enabled) then
|
||||
RaiseCannotFocus;
|
||||
SetWindowFocus;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -338,13 +354,6 @@ begin
|
||||
if (FormStyle <> fsMDIForm) or (csDesigning in ComponentState) then
|
||||
SetActive(Message.Active {<> WA_INACTIVE});
|
||||
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;
|
||||
end;
|
||||
|
||||
@ -667,7 +676,7 @@ begin
|
||||
LM_ACTIVATE, LM_SETFOCUS, LM_KILLFOCUS:
|
||||
begin
|
||||
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
|
||||
FocusHandle := 0;
|
||||
if FormStyle = fsMDIFORM
|
||||
@ -682,7 +691,9 @@ begin
|
||||
TheMessage.Result:=0;
|
||||
if FocusHandle <> 0
|
||||
then begin
|
||||
//writeln('[TCustomForm.WndPRoc] A ',FActiveControl.ClassName);
|
||||
{$IFDEF VerboseFocus}
|
||||
writeln('[TCustomForm.WndProc] ',Name,':',ClassName);
|
||||
{$ENDIF}
|
||||
LCLLinux.SetFocus(FocusHandle);
|
||||
Exit;
|
||||
end;
|
||||
@ -865,14 +876,18 @@ Begin
|
||||
then
|
||||
RaiseGDBException(SCannotFocus);
|
||||
// EInvalidOperation.Create(SCannotFocus);
|
||||
FActiveControl := AWinControl;
|
||||
{$IFDEF VerboseFocus}
|
||||
write('TCustomForm.SetActiveControl ',Name,':',ClassName,' FActive=',FActive);
|
||||
if FActiveControl<>nil then
|
||||
writeln(' FActiveControl=',FActiveControl.Name,':',FActiveControl.ClassName)
|
||||
writeln(' OldActiveControl=',FActiveControl.Name,':',FActiveControl.ClassName)
|
||||
else
|
||||
writeln(' FActiveControl=nil');
|
||||
writeln(' OldActiveControl=nil');
|
||||
if AWinControl<>nil then
|
||||
writeln(' NewActiveControl=',AWinControl.Name,':',AWinControl.ClassName)
|
||||
else
|
||||
writeln(' NewActiveControl=nil');
|
||||
{$ENDIF}
|
||||
FActiveControl := AWinControl;
|
||||
if not (csLoading in ComponentState) then
|
||||
begin
|
||||
if FActive then SetWindowFocus;
|
||||
@ -1114,6 +1129,8 @@ begin
|
||||
write(' Control=',Control.Name,':',Control.ClassName,' Control.HandleAllocated=',Control.HandleAllocated);
|
||||
writeln();
|
||||
{$ENDIF}
|
||||
|
||||
Result:=true;
|
||||
|
||||
{
|
||||
Inc(FocusCount);
|
||||
@ -1374,6 +1391,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$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
|
||||
improved focus debugging output
|
||||
|
||||
|
@ -106,10 +106,8 @@ begin
|
||||
break;
|
||||
end;
|
||||
until false;
|
||||
if NewFocusControl.HandleAllocated then begin
|
||||
LCLLinux.SetFocus(NewFocusControl.Handle);
|
||||
Key:=VK_UNKNOWN;
|
||||
end;
|
||||
ActiveControl:=NewFocusControl;
|
||||
Key:=VK_UNKNOWN;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -341,7 +339,7 @@ begin
|
||||
|
||||
for i:=0 to ComponentCount-1 do begin
|
||||
if (Components[i] is TBitBtn) and (TBitBtn(Components[i]).Default) then begin
|
||||
TBitBtn(Components[i]).SetFocus;
|
||||
ActiveControl:=TBitBtn(Components[i]);
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
@ -381,6 +379,9 @@ end;
|
||||
|
||||
{
|
||||
$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
|
||||
added localization for env options from Olivier
|
||||
|
||||
|
@ -31,6 +31,7 @@ begin
|
||||
FFonts := TStringlist.Create;
|
||||
TStringlist(FFonts).Sorted := True;
|
||||
FCustomForms:=TList.Create;
|
||||
FCustomFormsZOrdered:=TList.Create;
|
||||
FFormList := TList.Create;
|
||||
FPixelsPerInch:= ScreenInfo.PixelsPerInchX;
|
||||
FHintFont := TFont.Create;
|
||||
@ -54,6 +55,7 @@ begin
|
||||
FreeThenNil(FHintFont);
|
||||
FreeThenNil(FFormList);
|
||||
FreeThenNil(FCustomForms);
|
||||
FreeThenNil(FCustomFormsZOrdered);
|
||||
FreeThenNil(FSaveFocusedList);
|
||||
FreeThenNil(FFonts);
|
||||
inherited Destroy;
|
||||
@ -77,6 +79,15 @@ begin
|
||||
while (Result>=0) and (Forms[Result]<>AForm) do dec(Result);
|
||||
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;
|
||||
------------------------------------------------------------------------------}
|
||||
@ -173,6 +184,14 @@ begin
|
||||
Result := TCustomForm(FCustomForms[Index]);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
function TScreen.GetCustomFormsZOrdered(Index: Integer): TCustomForm;
|
||||
------------------------------------------------------------------------------}
|
||||
function TScreen.GetCustomFormsZOrdered(Index: Integer): TCustomForm;
|
||||
begin
|
||||
Result := TCustomForm(FCustomFormsZOrdered[Index]);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: TScreen.AddForm
|
||||
Params: FForm: The form to be added
|
||||
@ -183,6 +202,7 @@ end;
|
||||
procedure TScreen.AddForm(AForm: TCustomForm);
|
||||
begin
|
||||
FCustomForms.Add(AForm);
|
||||
FCustomFormsZOrdered.Add(AForm);
|
||||
if AForm is TForm then
|
||||
begin
|
||||
FFormList.Add(AForm);
|
||||
@ -249,6 +269,7 @@ end;
|
||||
procedure TScreen.RemoveForm(AForm: TCustomForm);
|
||||
begin
|
||||
FCustomForms.Remove(AForm);
|
||||
FCustomFormsZOrdered.Remove(AForm);
|
||||
FFormList.Remove(AForm);
|
||||
Application.UpdateVisible;
|
||||
//if (FCustomForms.Count = 0) and (Application.FHintWindow <> nil) then
|
||||
|
@ -168,6 +168,7 @@ ResourceString
|
||||
rsUnsupportedBitmapFormat = 'Unsupported bitmap format.';
|
||||
rsNoInterfaceObject = 'No interface object. '
|
||||
+'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