summaryrefslogtreecommitdiff
path: root/vcl/source/control
diff options
context:
space:
mode:
authorJustin Luth <jluth@mail.com>2023-06-22 14:29:15 -0400
committerJustin Luth <jluth@mail.com>2023-06-23 20:43:41 +0200
commit9f5393abea012be04ab7ecb26d8031019bc50f62 (patch)
treec287ed52138faca5c7e2603c49c85e968550109b /vcl/source/control
parentc968d8989004301b49d67a093a6eb8a629533837 (diff)
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 <jluth@mail.com>
Diffstat (limited to 'vcl/source/control')
-rw-r--r--vcl/source/control/tabctrl.cxx14
1 files changed, 12 insertions, 2 deletions
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;