diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-11-09 15:14:12 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-11-09 17:29:27 +0100 |
commit | 36d14442b25bd3d700d95879e5775cce6ed0836d (patch) | |
tree | e45eef6197fc97aad291c22efaccfd787a60b080 /svx | |
parent | 88a66f73f0182baffded6190f969bf7088236949 (diff) |
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@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/inc/findtextfield.hxx | 1 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbunosearchcontrollers.cxx | 20 |
2 files changed, 14 insertions, 7 deletions
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 { |