From f7eda562c6ac9782e3bb83d4be4feccfcf42d2da Mon Sep 17 00:00:00 2001 From: paul Date: Sat, 10 Jan 2009 12:55:04 +0000 Subject: [PATCH] win32: rewrite focusing while pages switching (bug #0012959) git-svn-id: trunk@18233 - --- lcl/interfaces/win32/win32wsextctrls.pp | 35 +++++++++---------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/lcl/interfaces/win32/win32wsextctrls.pp b/lcl/interfaces/win32/win32wsextctrls.pp index 08570b494a..9660bbda9b 100644 --- a/lcl/interfaces/win32/win32wsextctrls.pp +++ b/lcl/interfaces/win32/win32wsextctrls.pp @@ -226,36 +226,27 @@ end; procedure NotebookFocusNewControl(const ANotebook: TCustomNotebook; NewIndex: integer); var Page: TCustomPage; - ControlList: TFPList; - lWinControl: TWinControl; - I: integer; - FocusSet: Boolean; + AWinControl: TWinControl; + ParentForm: TCustomForm; begin { see if currently focused control is within notebook } if not IsNotebookGroupFocused(ANotebook) then exit; { focus was/is within notebook, pick a new control to focus } Page := ANotebook.CustomPage(NewIndex); - ControlList := TFPList.Create; - try - Page.GetTabOrderList(ControlList); - I := 0; - FocusSet := False; - while I < ControlList.Count do + ParentForm := GetParentForm(ANotebook); + if ParentForm <> nil then + begin + if ANotebook.ContainsControl(ParentForm.ActiveControl) and (ParentForm.ActiveControl <> ANotebook) then begin - lWinControl := TWinControl(ControlList[I]); - if lWinControl.TabStop and lWinControl.Enabled and lWinControl.CanFocus then - begin - lWinControl.SetFocus; - FocusSet := True; - break; - end; - Inc(I); + AWinControl := nil; + if Page.CanFocus then + AWinControl := TCustomPageAccess(Page).FindNextControl(nil, True, True, False); + // if nothing to focus then focus notebook then we can traverse pages by keys + if AWinControl = nil then + AWinControl := ANotebook; + AWinControl.SetFocus; end; - if not FocusSet then - Page.SetFocus; - finally - ControlList.Free; end; end;