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() )