summaryrefslogtreecommitdiff
path: root/sw/source/ui
diff options
context:
space:
mode:
authorDarshan-upadhyay1110 <darshan.upadhyay@collabora.com>2024-10-03 18:31:22 +0530
committerSzymon Kłos <szymon.klos@collabora.com>2024-11-08 16:42:36 +0100
commit65606ffdb9fbb133b7c771184fa97284fe6f2c91 (patch)
tree0ee643a075b83d12c28597e09add456914b91275 /sw/source/ui
parentdcfec9756c17689791b8dbc3495146ff6cc1fbb4 (diff)
Refactor focus handling in `LevelHdl` and `SwTokenWindow`
- Added a new `LevelHdlImpl` method with a `bool bGrabFocus` argument. - Refactored `LevelHdl` to call `LevelHdlImpl` with `true`. - Adjusted `SwTokenWindow::SetActiveControl` and `SwTokenWindow::SetForm` to skip `GrabFocus` when the argument is `false`. - Ensured focus behavior remains unchanged except for the initial "ActivatePage". Change-Id: If2f43e43f94c3762acd93974550ff0d2d66c6c21 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174423 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> (cherry picked from commit dbb054045fae8605794c17aae052a9d588fe33fc) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175996 Tested-by: Jenkins
Diffstat (limited to 'sw/source/ui')
-rw-r--r--sw/source/ui/index/cnttab.cxx37
1 files changed, 24 insertions, 13 deletions
diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx
index e530a1c5e61d..56b9c1f07068 100644
--- a/sw/source/ui/index/cnttab.cxx
+++ b/sw/source/ui/index/cnttab.cxx
@@ -2273,7 +2273,7 @@ void SwTOXEntryTabPage::ActivatePage( const SfxItemSet& /*rSet*/)
//invalidate PatternWindow
m_xTokenWIN->SetInvalid();
- LevelHdl(*m_xLevelLB);
+ LevelHdlImpl(*m_xLevelLB, false);
}
void SwTOXEntryTabPage::UpdateDescriptor()
@@ -2447,20 +2447,21 @@ void SwTOXEntryTabPage::WriteBackLevel()
}
}
-IMPL_LINK(SwTOXEntryTabPage, LevelHdl, weld::TreeView&, rBox, void)
+void SwTOXEntryTabPage::LevelHdlImpl(weld::TreeView& rBox, bool bGrabFocus)
{
- if(m_bInLevelHdl)
+ if (m_bInLevelHdl)
return;
m_bInLevelHdl = true;
WriteBackLevel();
const sal_uInt16 nLevel = rBox.get_selected_index();
- m_xTokenWIN->SetForm(*m_pCurrentForm, nLevel);
+ m_xTokenWIN->SetForm(*m_pCurrentForm, nLevel, bGrabFocus);
+
if(TOX_AUTHORITIES == m_pCurrentForm->GetTOXType())
{
//fill the types in
m_xAuthFieldsLB->clear();
- for( sal_uInt32 i = 0; i < AUTH_FIELD_END; i++)
+ for(sal_uInt32 i = 0; i < AUTH_FIELD_END; i++)
{
m_xAuthFieldsLB->append(OUString::number(i), SwResId(STR_AUTH_FIELD_ARY[i]));
}
@@ -2481,9 +2482,19 @@ IMPL_LINK(SwTOXEntryTabPage, LevelHdl, weld::TreeView&, rBox, void)
m_xAuthFieldsLB->set_active(0);
}
m_bInLevelHdl = false;
- rBox.grab_focus();
+
+ if (bGrabFocus)
+ {
+ rBox.grab_focus();
+ }
}
+IMPL_LINK(SwTOXEntryTabPage, LevelHdl, weld::TreeView&, rBox, void)
+{
+ LevelHdlImpl(rBox, true);
+}
+
+
IMPL_LINK_NOARG(SwTOXEntryTabPage, SortKeyHdl, weld::Toggleable&, void)
{
bool bEnable = m_xSortContentRB->get_active();
@@ -2802,9 +2813,9 @@ SwTokenWindow::~SwTokenWindow()
{
}
-void SwTokenWindow::SetForm(SwForm& rForm, sal_uInt16 nL)
+void SwTokenWindow::SetForm(SwForm& rForm, sal_uInt16 nL, bool bGrabFocus)
{
- SetActiveControl(nullptr);
+ SetActiveControl(nullptr, bGrabFocus);
m_bValid = true;
if (m_pForm)
@@ -2831,7 +2842,7 @@ void SwTokenWindow::SetForm(SwForm& rForm, sal_uInt16 nL)
SwTOXWidget* pCtrl = InsertItem(aToken.sText, aToken);
bLastWasText = true;
if (!GetActiveControl())
- SetActiveControl(pCtrl);
+ SetActiveControl(pCtrl, bGrabFocus);
}
else
{
@@ -2869,12 +2880,12 @@ void SwTokenWindow::SetForm(SwForm& rForm, sal_uInt16 nL)
if(!pSetActiveControl)
pSetActiveControl = pCtrl;
}
- SetActiveControl(pSetActiveControl);
+ SetActiveControl(pSetActiveControl, bGrabFocus);
}
AdjustScrolling();
}
-void SwTokenWindow::SetActiveControl(SwTOXWidget* pSet)
+void SwTokenWindow::SetActiveControl(SwTOXWidget* pSet, bool bGrabFocus)
{
if (pSet == m_pActiveCtrl)
return;
@@ -2882,8 +2893,8 @@ void SwTokenWindow::SetActiveControl(SwTOXWidget* pSet)
m_pActiveCtrl = pSet;
if( !m_pActiveCtrl )
return;
-
- m_pActiveCtrl->GrabFocus();
+ if (bGrabFocus)
+ m_pActiveCtrl->GrabFocus();
//it must be a SwTOXEdit
const SwFormToken* pFToken;
if( WindowType::EDIT == m_pActiveCtrl->GetType() )