From 49bfaecb787b38a0c69ef2d43afd18b7e41bc738 Mon Sep 17 00:00:00 2001 From: michl Date: Wed, 25 Jan 2017 20:38:27 +0000 Subject: [PATCH] LCL: TPageControl: Showing correct tab for a page with TabVisible = False. Issue #21723 git-svn-id: trunk@54003 - --- lcl/include/customnotebook.inc | 6 ++++++ lcl/interfaces/gtk2/gtk2pagecontrol.inc | 3 +++ 2 files changed, 9 insertions(+) diff --git a/lcl/include/customnotebook.inc b/lcl/include/customnotebook.inc index 0e6a0e6261..42e519f261 100644 --- a/lcl/include/customnotebook.inc +++ b/lcl/include/customnotebook.inc @@ -449,6 +449,12 @@ begin Result := AIndex; if csDesigning in ComponentState then exit; //all pages are visible + + // it is possible to show pages without visible tabs, but then, no tab index + // can be sendet back, issue #21723 + if not Page[AIndex].TabVisible then + exit(-1); + for i := 0 to AIndex - 1 do begin if not Page[i].TabVisible then dec(Result); //exclude invisible page diff --git a/lcl/interfaces/gtk2/gtk2pagecontrol.inc b/lcl/interfaces/gtk2/gtk2pagecontrol.inc index 42e605247f..626f83666a 100644 --- a/lcl/interfaces/gtk2/gtk2pagecontrol.inc +++ b/lcl/interfaces/gtk2/gtk2pagecontrol.inc @@ -553,6 +553,9 @@ begin Exit; if (AIndex < 0) or (AIndex > ATabControl.PageCount - 1) then exit; + ANewIndex:=ATabControl.PageToTabIndex(AIndex); + if (ANewIndex < 0) then + exit; GtkNotebook := {%H-}PGtkNoteBook(ATabControl.Handle); if gtk_notebook_get_current_page(GtkNotebook) <> AIndex then begin