summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-07-28 12:33:15 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-07-28 16:25:12 +0200
commit50b36951dbf080509c49bf326131afb8c2390d2d (patch)
treee5d07604625b4ebafde69aa66a226034a1fb5468 /sw
parent720b3c133cc6348537b4d013b4531856f73b392d (diff)
tdf#134959 move focus on activate, but leave focus on value-changed
if the user presses enter to activate the Entry try to go to the page, and on success we move focus to the document. if the SpinButton changed value a Timer was launched, when it times-out, move to the desired page, but leave focus where it currently is, i.e. typically remaining in the spinbutton, or whatever other widget the user moved to in the meantime This replaces always grabbing focus to the document on a page-change and re-grabbing focus back to the spinbutton. Change-Id: I597597aedb1753aee755671a2a55779ca6196c09 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99611 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/inc/navipi.hxx1
-rw-r--r--sw/source/uibase/utlui/navipi.cxx21
2 files changed, 15 insertions, 7 deletions
diff --git a/sw/source/uibase/inc/navipi.hxx b/sw/source/uibase/inc/navipi.hxx
index 14e066c73380..fee94525d577 100644
--- a/sw/source/uibase/inc/navipi.hxx
+++ b/sw/source/uibase/inc/navipi.hxx
@@ -107,6 +107,7 @@ class SwNavigationPI : public PanelLayout
DECL_LINK( GlobalMenuSelectHdl, const OString&, void );
DECL_LINK( ChangePageHdl, Timer*, void );
DECL_LINK( PageEditModifyHdl, weld::SpinButton&, void );
+ DECL_LINK( EditActionHdl, weld::Entry&, bool );
bool EditAction();
void UsePage();
diff --git a/sw/source/uibase/utlui/navipi.cxx b/sw/source/uibase/utlui/navipi.cxx
index 0e3af56e48ec..577aba8fc645 100644
--- a/sw/source/uibase/utlui/navipi.cxx
+++ b/sw/source/uibase/utlui/navipi.cxx
@@ -412,13 +412,7 @@ bool SwNavigationPI::EditAction()
SwWrtShell &rSh = m_pCreateView->GetWrtShell();
sal_uInt16 nNewPage = m_xEdit->get_value();
- sal_uInt16 nPhyPage, nVirPage;
- rSh.GetPageNum(nPhyPage, nVirPage);
- if (nPhyPage == nNewPage)
- return false;
-
rSh.GotoPage(nNewPage, true);
- m_pCreateView->GetEditWin().GrabFocus();
m_pCreateView->GetViewFrame()->GetBindings().Invalidate(FN_STAT_PAGE);
return true;
@@ -554,6 +548,7 @@ SwNavigationPI::SwNavigationPI(vcl::Window* pParent,
// Insert the numeric field in the toolbox.
m_xEdit->set_accessible_name(m_xEdit->get_tooltip_text());
m_xEdit->set_width_chars(3);
+ m_xEdit->connect_activate(LINK(this, SwNavigationPI, EditActionHdl));
m_xEdit->connect_value_changed(LINK(this, SwNavigationPI, PageEditModifyHdl));
m_xEdit->set_help_id("modules/swriter/ui/navigatorpanel/numericfield");
@@ -1054,8 +1049,20 @@ IMPL_LINK_NOARG(SwNavigationPI, ChangePageHdl, Timer *, void)
{
if (IsDisposed())
return;
+ // tdf#134959 if the SpinButton changed value this Timer was launched, now
+ // change to the desired page, but we leave focus where it currently is,
+ // i.e. typically remaining in the spinbutton, or whatever other widget the
+ // user moved to in the meantime
+ EditAction();
+}
+
+IMPL_LINK_NOARG(SwNavigationPI, EditActionHdl, weld::Entry&, bool)
+{
+ // tdf#134959 if the user presses enter to activate the Entry
+ // go to the page, and on success we move focus to the document
if (EditAction())
- m_xEdit->grab_focus();
+ m_pCreateView->GetEditWin().GrabFocus();
+ return true;
}
IMPL_LINK_NOARG(SwNavigationPI, PageEditModifyHdl, weld::SpinButton&, void)