From ea828798684192dc8a723050c30d35ebba62e250 Mon Sep 17 00:00:00 2001 From: dopi Date: Fri, 29 Sep 2017 02:09:24 +0000 Subject: [PATCH] 27/09/2017 [-] Fix for Method "RestoreLastFocusedControl". Wrong last focused component detection [-] Fix for Closed Buttom Enabled/Disabled detection when Creating and Closing Pages Lazarus 1.8 (by: DSA) git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6023 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/tdi/read-me.txt | 7 +++++++ components/tdi/tdiclass.pas | 30 +++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/components/tdi/read-me.txt b/components/tdi/read-me.txt index baba6ce6d..b7823f1e4 100644 --- a/components/tdi/read-me.txt +++ b/components/tdi/read-me.txt @@ -171,3 +171,10 @@ to explain the component [-] Better detection for Form Constraint handling on Linux (by: DSA and Galló Gábor) +27/09/2017 +[-] Fix for Method "RestoreLastFocusedControl". Wrong last focused component + detection +[-] Fix for Closed Buttom Enabled/Disabled detection when Creating and Closing Pages + Lazarus 1.8 + (by: DSA) + diff --git a/components/tdi/tdiclass.pas b/components/tdi/tdiclass.pas index bafe850f2..150093e28 100644 --- a/components/tdi/tdiclass.pas +++ b/components/tdi/tdiclass.pas @@ -283,22 +283,28 @@ begin end ; procedure TTDIPage.RestoreLastFocusedControl ; +var + FocusRestored: Boolean; begin + FocusRestored := False; + if Assigned( fsLastActiveControl ) then begin if fsLastActiveControl <> Screen.ActiveControl then begin - if fsLastActiveControl.Visible and fsLastActiveControl.Enabled then + if fsLastActiveControl.CanSetFocus then begin try - fsLastActiveControl.SetFocus ; + fsLastActiveControl.SetFocus; + FocusRestored := True; //FormInPage.ActiveControl := fsLastActiveControl; except end ; end ; end - end - else + end; + + if not FocusRestored then begin { No LastActiveControle ? Ok, if current Screen control isn't in TabSheet, go to first Control on TabSheet... } @@ -709,9 +715,10 @@ procedure TTDINoteBook.ShowFormInPage(AForm : TForm ; ImageIndex : Integer) ; Var NewPage : TTDIPage ; AlreadyExistingPage : Integer ; + DoCheckInterface: Boolean; begin if not Assigned( AForm ) then - raise ETDIError.Create( sFormNotAssigned ) ; + raise ETDIError.Create( sFormNotAssigned ) ; // Looking for a Page with same AForm Object // AlreadyExistingPage := FindFormInPages( AForm ); @@ -721,6 +728,8 @@ begin exit ; end ; + DoCheckInterface := (PageCount = 1); + // Create a new Page NewPage := TTDIPage.Create(Self); NewPage.ImageIndex := ImageIndex; @@ -745,7 +754,7 @@ begin AForm.Align := alClient; // Try to expand the Form NewPage.CheckFormAlign ; - if PageCount = 1 then + if DoCheckInterface then CheckInterface; end ; @@ -1114,9 +1123,12 @@ end ; procedure TTDINoteBook.RemovePage(Index : Integer) ; Var - CanRemovePage : Boolean ; - APage : TTabSheet; + CanRemovePage: Boolean ; + APage: TTabSheet; begin + if (Index >= PageCount) or (Index < 0) then + Exit; + CanRemovePage := True; FIsRemovingAPage := True; APage := Pages[Index] ; @@ -1144,7 +1156,7 @@ begin APage.Free; {$endif} - if PageCount < 1 then // On this case, DoChange is not fired // + if (PageCount <= 1) then // In this situation... DoChange is not fired // CheckInterface; end ; finally