From 8c74d9b30aacec2207dd6c7960c81280c79e2c31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Wed, 17 Jun 2020 16:47:15 +0100 Subject: [PATCH] ignore positions on top of scrollbars for GetTargetAtPoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I6d63ac3723b392e7c82836ea5d4455ebde8a8e08 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96553 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- include/vcl/treelistbox.hxx | 4 ++++ vcl/inc/treeglue.hxx | 2 +- vcl/source/treelist/treelistbox.cxx | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/include/vcl/treelistbox.hxx b/include/vcl/treelistbox.hxx index ac24996221cc..1fe73c689610 100644 --- a/include/vcl/treelistbox.hxx +++ b/include/vcl/treelistbox.hxx @@ -557,6 +557,10 @@ protected: void ImplEditEntry( SvTreeListEntry* pEntry ); void AdjustEntryHeightAndRecalc(); + + // true if rPos is over the SvTreeListBox body, i.e. not over a + // scrollbar + VCL_DLLPRIVATE bool PosOverBody(const Point& rPos) const; public: void SetNoAutoCurEntry( bool b ); diff --git a/vcl/inc/treeglue.hxx b/vcl/inc/treeglue.hxx index 11c61944f5e1..ea643635faee 100644 --- a/vcl/inc/treeglue.hxx +++ b/vcl/inc/treeglue.hxx @@ -130,7 +130,7 @@ public: SvTreeListEntry* GetTargetAtPoint(const Point& rPos, bool bHighLightTarget) { SvTreeListEntry* pOldTargetEntry = pTargetEntry; - pTargetEntry = pImpl->GetEntry(rPos); + pTargetEntry = PosOverBody(rPos) ? pImpl->GetEntry(rPos) : nullptr; if (pOldTargetEntry != pTargetEntry) ImplShowTargetEmphasis(pOldTargetEntry, false); diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx index e41a11d0f103..a31f86e81f45 100644 --- a/vcl/source/treelist/treelistbox.cxx +++ b/vcl/source/treelist/treelistbox.cxx @@ -1996,6 +1996,28 @@ void SvTreeListBox::ModelHasCleared() SvListView::ModelHasCleared(); } +bool SvTreeListBox::PosOverBody(const Point& rPos) const +{ + if (rPos.X() < 0 || rPos.Y() < 0) + return false; + Size aSize(GetSizePixel()); + if (rPos.X() > aSize.Width() || rPos.Y() > aSize.Height()) + return false; + if (pImpl->m_aVerSBar->IsVisible()) + { + tools::Rectangle aRect(pImpl->m_aVerSBar->GetPosPixel(), pImpl->m_aVerSBar->GetSizePixel()); + if (aRect.IsInside(rPos)) + return false; + } + if (pImpl->m_aHorSBar->IsVisible()) + { + tools::Rectangle aRect(pImpl->m_aHorSBar->GetPosPixel(), pImpl->m_aHorSBar->GetSizePixel()); + if (aRect.IsInside(rPos)) + return false; + } + return true; +} + void SvTreeListBox::ScrollOutputArea( short nDeltaEntries ) { if( !nDeltaEntries || !pImpl->m_aVerSBar->IsVisible() )