vcl/source/control/tabctrl.cxx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
New commits: commit 9f5393abea012be04ab7ecb26d8031019bc50f62 Author: Justin Luth <jl...@mail.com> AuthorDate: Thu Jun 22 14:29:15 2023 -0400 Commit: Justin Luth <jl...@mail.com> CommitDate: Fri Jun 23 20:43:41 2023 +0200 tdf#141136 NBB SetContext: try to stay on the same tab The user was forced on the HOME page at almost any context change. Instead, this should only happen if: -there is a special context tab -there is no special tab, and some "random" tab is needed. This helps in a lot of cases, but there are still plenty of cases where TWO context changes are emitted for one logical event. For example, in Calc a new comment switches to special DRAW tab, and then immediately to DrawText which has no tab -> home tab. So further fixes are needed to prevent machine-gun fire context events. Change-Id: Ibaf18fa823c613b4d11d33284842e439d3689542 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153476 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index c384cb036db6..d44554b80b83 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -2285,17 +2285,27 @@ void NotebookbarTabControlBase::SetContext( vcl::EnumContext::Context eContext ) bool bHandled = false; + TabPage* pPage = GetTabPage(mnCurPageId); + // Try to stay on the current tab (unless the new context has a special tab) + if (pPage && eLastContext != vcl::EnumContext::Context::Any + && pPage->HasContext(vcl::EnumContext::Context::Any) && pPage->IsEnabled()) + { + bHandled = true; + } + for (int nChild = 0; nChild < GetPageCount(); ++nChild) { sal_uInt16 nPageId = TabControl::GetPageId(nChild); - TabPage* pPage = GetTabPage(nPageId); + pPage = GetTabPage(nPageId); if (!pPage) continue; SetPageVisible(nPageId, pPage->HasContext(eContext) || pPage->HasContext(vcl::EnumContext::Context::Any)); - if (pPage->HasContext(eContext) && eContext != vcl::EnumContext::Context::Any) + if (eContext != vcl::EnumContext::Context::Any + && (!bHandled || !pPage->HasContext(vcl::EnumContext::Context::Any)) + && pPage->HasContext(eContext)) { SetCurPageId(nPageId); bHandled = true;