[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - dbaccess/source include/svtools svtools/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Thu Oct 1 07:56:08 UTC 2020
dbaccess/source/ui/control/RelationControl.cxx | 2 +-
include/svtools/editbrowsebox.hxx | 25 +++++++++++++++++++++++--
svtools/source/brwbox/ebbcontrols.cxx | 8 ++++----
svtools/source/brwbox/editbrowsebox.cxx | 13 ++++++++++---
svtools/source/brwbox/editbrowsebox2.cxx | 2 +-
5 files changed, 39 insertions(+), 11 deletions(-)
New commits:
commit 9d30d3bb93171a12655dc89066fe065e2c2af658
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun Sep 27 20:06:17 2020 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Oct 1 09:55:35 2020 +0200
Related: tdf#137016 check if subcontrol has the focus
backport some required pieces from master to support that
Change-Id: I632188bc0512c9d8935bd0898c96e066881ebeb1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103524
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/dbaccess/source/ui/control/RelationControl.cxx b/dbaccess/source/ui/control/RelationControl.cxx
index d9de91ba494b..69f0a00cae2d 100644
--- a/dbaccess/source/ui/control/RelationControl.cxx
+++ b/dbaccess/source/ui/control/RelationControl.cxx
@@ -184,7 +184,7 @@ namespace dbaui
bool ORelationControl::PreNotify(NotifyEvent& rNEvt)
{
- if (rNEvt.GetType() == MouseNotifyEvent::LOSEFOCUS && !HasChildPathFocus() )
+ if (rNEvt.GetType() == MouseNotifyEvent::LOSEFOCUS && !HasChildPathFocus() && !ControlHasFocus())
PostUserEvent(LINK(this, ORelationControl, AsynchDeactivate), nullptr, true);
else if (rNEvt.GetType() == MouseNotifyEvent::GETFOCUS)
PostUserEvent(LINK(this, ORelationControl, AsynchActivate), nullptr, true);
diff --git a/include/svtools/editbrowsebox.hxx b/include/svtools/editbrowsebox.hxx
index ebd968d254ad..5614659d0756 100644
--- a/include/svtools/editbrowsebox.hxx
+++ b/include/svtools/editbrowsebox.hxx
@@ -316,8 +316,18 @@ namespace svt
DECL_LINK(ModifyHdl, LinkParamNone*, void);
};
+ class SVT_DLLPUBLIC ControlBase : public InterimItemWindow
+ {
+ public:
+ ControlBase(vcl::Window* pParent, const OUString& rUIXMLDescription, const OString& rID)
+ : InterimItemWindow(pParent, rUIXMLDescription, rID)
+ {
+ }
+ virtual bool ControlHasFocus() const = 0;
+ };
+
//= ComboBoxControl
- class SVT_DLLPUBLIC ComboBoxControl final : public InterimItemWindow
+ class SVT_DLLPUBLIC ComboBoxControl final : public ControlBase
{
private:
std::unique_ptr<weld::ComboBox> m_xWidget;
@@ -343,6 +353,11 @@ namespace svt
m_aModify2Hdl = rLink;
}
+ virtual bool ControlHasFocus() const override
+ {
+ return m_xWidget && m_xWidget->has_focus();
+ }
+
virtual void dispose() override;
private:
@@ -373,7 +388,7 @@ namespace svt
};
//= ListBoxControl
- class SVT_DLLPUBLIC ListBoxControl final : public InterimItemWindow
+ class SVT_DLLPUBLIC ListBoxControl final : public ControlBase
{
private:
std::unique_ptr<weld::ComboBox> m_xWidget;
@@ -399,6 +414,11 @@ namespace svt
m_aModify2Hdl = rLink;
}
+ virtual bool ControlHasFocus() const override
+ {
+ return m_xWidget && m_xWidget->has_focus();
+ }
+
virtual void dispose() override;
private:
DECL_LINK(SelectHdl, weld::ComboBox&, void);
@@ -655,6 +675,7 @@ namespace svt
virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint) override;
css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleCheckBoxCell(long _nRow, sal_uInt16 _nColumnPos,const TriState& eState);
+ bool ControlHasFocus() const;
protected:
// creates the accessible which wraps the active cell
void implCreateActiveAccessible( );
diff --git a/svtools/source/brwbox/ebbcontrols.cxx b/svtools/source/brwbox/ebbcontrols.cxx
index 1e0272aeeea9..e402f0a42a40 100644
--- a/svtools/source/brwbox/ebbcontrols.cxx
+++ b/svtools/source/brwbox/ebbcontrols.cxx
@@ -28,7 +28,7 @@ namespace svt
//= ComboBoxControl
ComboBoxControl::ComboBoxControl(vcl::Window* pParent)
- : InterimItemWindow(pParent, "svt/ui/combocontrol.ui", "ComboControl")
+ : ControlBase(pParent, "svt/ui/combocontrol.ui", "ComboControl")
, m_xWidget(m_xBuilder->weld_combo_box("combobox"))
{
m_xWidget->set_entry_width_chars(1); // so a smaller than default width can be used
@@ -38,7 +38,7 @@ namespace svt
void ComboBoxControl::dispose()
{
m_xWidget.reset();
- InterimItemWindow::dispose();
+ ControlBase::dispose();
}
IMPL_LINK_NOARG(ComboBoxControl, SelectHdl, weld::ComboBox&, void)
@@ -111,7 +111,7 @@ namespace svt
//= ListBoxControl
ListBoxControl::ListBoxControl(vcl::Window* pParent)
- : InterimItemWindow(pParent, "svt/ui/listcontrol.ui", "ListControl")
+ : ControlBase(pParent, "svt/ui/listcontrol.ui", "ListControl")
, m_xWidget(m_xBuilder->weld_combo_box("listbox"))
{
m_xWidget->set_size_request(42, -1); // so a later narrow size request can stick
@@ -121,7 +121,7 @@ namespace svt
void ListBoxControl::dispose()
{
m_xWidget.reset();
- InterimItemWindow::dispose();
+ ControlBase::dispose();
}
IMPL_LINK_NOARG(ListBoxControl, SelectHdl, weld::ComboBox&, void)
diff --git a/svtools/source/brwbox/editbrowsebox.cxx b/svtools/source/brwbox/editbrowsebox.cxx
index 0105082cea5c..12ef6d6fd181 100644
--- a/svtools/source/brwbox/editbrowsebox.cxx
+++ b/svtools/source/brwbox/editbrowsebox.cxx
@@ -211,7 +211,7 @@ namespace svt
if (IsEditing())
{
EnableAndShow();
- if (!aController->GetWindow().HasFocus() && (m_pFocusWhileRequest.get() == Application::GetFocusWindow()))
+ if (!ControlHasFocus() && (m_pFocusWhileRequest.get() == Application::GetFocusWindow()))
aController->GetWindow().GrabFocus();
}
}
@@ -467,6 +467,13 @@ namespace svt
implActivateCellOnMouseEvent(rEvt, true);
}
+ bool EditBrowseBox::ControlHasFocus() const
+ {
+ Window* pControlWindow = aController ? &aController->GetWindow() : nullptr;
+ if (ControlBase* pControlBase = dynamic_cast<ControlBase*>(pControlWindow))
+ return pControlBase->ControlHasFocus();
+ return pControlWindow && pControlWindow->HasChildPathFocus();
+ }
void EditBrowseBox::implActivateCellOnMouseEvent(const BrowserMouseEvent& _rEvt, bool _bUp)
{
@@ -474,7 +481,7 @@ namespace svt
ActivateCell();
else if (IsEditing() && !aController->GetWindow().IsEnabled())
DeactivateCell();
- else if (IsEditing() && !aController->GetWindow().HasChildPathFocus())
+ else if (IsEditing() && !ControlHasFocus())
AsynchGetFocus();
if (!(IsEditing() && aController->GetWindow().IsEnabled() && aController->WantMouseEvent()))
@@ -546,7 +553,7 @@ namespace svt
{
if (rEvt.GetType() == MouseNotifyEvent::KEYINPUT)
{
- if ( (IsEditing() && Controller()->GetWindow().HasChildPathFocus())
+ if ( (IsEditing() && ControlHasFocus())
|| rEvt.GetWindow() == &GetDataWindow()
|| (!IsEditing() && HasChildPathFocus())
)
diff --git a/svtools/source/brwbox/editbrowsebox2.cxx b/svtools/source/brwbox/editbrowsebox2.cxx
index 3544979e725b..7c84cf5eb805 100644
--- a/svtools/source/brwbox/editbrowsebox2.cxx
+++ b/svtools/source/brwbox/editbrowsebox2.cxx
@@ -124,7 +124,7 @@ void EditBrowseBox::GrabTableFocus()
void EditBrowseBox::DetermineFocus( const GetFocusFlags _nGetFocusFlags )
{
- bool bFocus = false;
+ bool bFocus = ControlHasFocus();
for (vcl::Window* pWindow = Application::GetFocusWindow();
pWindow && !bFocus;
pWindow = pWindow->GetParent())
More information about the Libreoffice-commits
mailing list