[Libreoffice-commits] core.git: svx/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon Nov 9 16:30:03 UTC 2020


 svx/source/inc/findtextfield.hxx               |    1 +
 svx/source/tbxctrls/tbunosearchcontrollers.cxx |   20 +++++++++++++-------
 2 files changed, 14 insertions(+), 7 deletions(-)

New commits:
commit 36d14442b25bd3d700d95879e5775cce6ed0836d
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Nov 9 15:14:12 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Nov 9 17:29:27 2020 +0100

    tdf#137993 ensure the toplevel vcl::Window is activated
    
    when the search entry gains focus so that SfxViewFrame::Current is valid
    
    Change-Id: Ibb21db12688a7d44758cf607da618035c22a062a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105484
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/svx/source/inc/findtextfield.hxx b/svx/source/inc/findtextfield.hxx
index 1ac5519a2dcd..3e5de483c91a 100644
--- a/svx/source/inc/findtextfield.hxx
+++ b/svx/source/inc/findtextfield.hxx
@@ -63,6 +63,7 @@ private:
     DECL_LINK(ActivateHdl, weld::ComboBox&, bool);
     DECL_LINK(OnAsyncGetFocus, void*, void);
 
+    void FocusIn();
     void ActivateFind(bool bShift);
 };
 
diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx
index 812d0bef4361..9d389139f18f 100644
--- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx
+++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx
@@ -200,6 +200,8 @@ FindTextFieldControl::FindTextFieldControl( vcl::Window* pParent,
     m_xContext(xContext),
     m_pAcc(svt::AcceleratorExecute::createAcceleratorHelper())
 {
+    InitControlBase(m_xWidget.get());
+
     m_xWidget->set_entry_placeholder_text(SvxResId(RID_SVXSTR_FINDBAR_FIND));
     m_xWidget->set_entry_completion(true, true);
     m_pAcc->init(m_xContext, m_xFrame);
@@ -340,12 +342,20 @@ IMPL_LINK_NOARG(FindTextFieldControl, OnAsyncGetFocus, void*, void)
     m_xWidget->select_entry_region(0, -1);
 }
 
-IMPL_LINK_NOARG(FindTextFieldControl, FocusInHdl, weld::Widget&, void)
+void FindTextFieldControl::FocusIn()
 {
-    if (m_nAsyncGetFocusId)
+    if (m_nAsyncGetFocusId || !m_xWidget)
         return;
+
     // do it async to defeat entry in combobox having its own ideas about the focus
     m_nAsyncGetFocusId = Application::PostUserEvent(LINK(this, FindTextFieldControl, OnAsyncGetFocus));
+
+    GrabFocus(); // tdf#137993 ensure the toplevel vcl::Window is activated so SfxViewFrame::Current is valid
+}
+
+IMPL_LINK_NOARG(FindTextFieldControl, FocusInHdl, weld::Widget&, void)
+{
+    FocusIn();
 }
 
 void FindTextFieldControl::dispose()
@@ -397,12 +407,8 @@ void FindTextFieldControl::set_entry_message_type(weld::EntryMessageType eType)
 
 void FindTextFieldControl::GetFocus()
 {
-    if (m_xWidget)
-    {
-        m_xWidget->grab_focus();
-        FocusInHdl(*m_xWidget);
-    }
     InterimItemWindow::GetFocus();
+    FocusIn();
 }
 
 namespace {


More information about the Libreoffice-commits mailing list