summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Le Grand (Allotropia) <Armin.Le.Grand@me.com>2021-07-28 19:01:15 +0200
committerArmin Le Grand <Armin.Le.Grand@me.com>2021-07-31 18:37:01 +0200
commitca7dab5d96e73b7b4b045e2460e0b2ee150757db (patch)
tree2edf938e81dbea8bfc707958f257dabf55dacede
parent95f5c4fb555407461fc1ab41aedbb9043105b9d6 (diff)
tdf#143114 Avoid StartDrag on TreeListBox when CaptureOnButton
The original method SvTreeListBox::StartDrag always triggers a MouseButtonUp event and tries to initiate a Drag of a Line of a TreeListBox (on MouseMove, btw). This is not wanted if the last MouseButtonDown started a ButtonActive mode and activated CaptureMouse, prepared to trigger Action on that Button on MouseButtonUp. It leads to unwanted/strange behaviour of Buttons/CheckBoxes when used in TreeListBoxes. The behaviour is also dependent on the UI implementation used under Linux (gen/gtk3_kde5/gtk3/qt5/kf5) which are all (unfortunately) behaving differently, but a first suggestion/ step to enhance the situation. Found now for gen/qt5/kf5 that when on the LineEntry, but not on the CheckBox, on MouseButtonUp the other line gets switched. Corrected that. Note: for gtk3_kde5/gtk3 there remains the problem that the CheckBoxes get switched on MouseButtonDown, butt these are generic widgets and this needs to be solved differently. Change-Id: If4cfe894b716185293beff64fc7e482d6f6313d3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119644 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
-rw-r--r--vcl/inc/svimpbox.hxx9
-rw-r--r--vcl/source/treelist/svimpbox.cxx1
-rw-r--r--vcl/source/treelist/treelistbox.cxx24
3 files changed, 27 insertions, 7 deletions
diff --git a/vcl/inc/svimpbox.hxx b/vcl/inc/svimpbox.hxx
index 554c5a8070ae..c46003c35dd4 100644
--- a/vcl/inc/svimpbox.hxx
+++ b/vcl/inc/svimpbox.hxx
@@ -310,8 +310,17 @@ public:
bool IsSelectable( const SvTreeListEntry* pEntry );
void SetForceMakeVisible(bool bEnable) { mbForceMakeVisible = bEnable; }
+
+ // tdf#143114 allow to ask if CaptureOnButton is active
+ // (MouseButtonDown hit on SvLBoxButton, CaptureMouse() active)
+ bool IsCaptureOnButtonActive() const;
};
+inline bool SvImpLBox::IsCaptureOnButtonActive() const
+{
+ return nullptr != m_pActiveButton && nullptr != m_pActiveEntry;
+}
+
inline Image& SvImpLBox::implGetImageLocation( const ImageType _eType )
{
return m_aNodeAndEntryImages[_eType];
diff --git a/vcl/source/treelist/svimpbox.cxx b/vcl/source/treelist/svimpbox.cxx
index 835ee2eac949..0b4f1e50d122 100644
--- a/vcl/source/treelist/svimpbox.cxx
+++ b/vcl/source/treelist/svimpbox.cxx
@@ -1794,7 +1794,6 @@ void SvImpLBox::EntryInserted( SvTreeListEntry* pEntry )
// ****** Control the control animation
-
bool SvImpLBox::ButtonDownCheckCtrl(const MouseEvent& rMEvt, SvTreeListEntry* pEntry)
{
SvLBoxItem* pItem = m_pView->GetItem(pEntry,rMEvt.GetPosPixel().X(),&m_pActiveTab);
diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx
index 278f42dde1c2..2338292820e9 100644
--- a/vcl/source/treelist/treelistbox.cxx
+++ b/vcl/source/treelist/treelistbox.cxx
@@ -1108,9 +1108,13 @@ void SvTreeListBox::SetupDragOrigin()
void SvTreeListBox::StartDrag( sal_Int8, const Point& rPosPixel )
{
- Point aEventPos( rPosPixel );
- MouseEvent aMouseEvt( aEventPos, 1, MouseEventModifiers::SELECT, MOUSE_LEFT );
- MouseButtonUp( aMouseEvt );
+ if(nullptr != pImpl)
+ {
+ // tdf#143114 do not start drag when a Button/Checkbox is in
+ // drag-before-ButtonUp mode (CaptureMouse() active)
+ if(pImpl->IsCaptureOnButtonActive())
+ return;
+ }
nOldDragMode = GetDragDropMode();
if ( nOldDragMode == DragDropMode::NONE )
@@ -2282,18 +2286,26 @@ void SvTreeListBox::Paint(vcl::RenderContext& rRenderContext, const tools::Recta
void SvTreeListBox::MouseButtonDown( const MouseEvent& rMEvt )
{
- pImpl->m_pCursorOld = pImpl->m_pCursor;
pImpl->MouseButtonDown( rMEvt );
+
+ // tdf#143114 remember the *correct* starting entry
+ pImpl->m_pCursorOld = (rMEvt.IsLeft() && (nTreeFlags & SvTreeFlags::CHKBTN) && mnClicksToToggle > 0)
+ ? GetEntry(rMEvt.GetPosPixel())
+ : nullptr;
}
void SvTreeListBox::MouseButtonUp( const MouseEvent& rMEvt )
{
// tdf#116675 clicking on an entry should toggle its checkbox
- if (rMEvt.IsLeft() && (nTreeFlags & SvTreeFlags::CHKBTN) && mnClicksToToggle > 0)
+ // tdf#143114 use the already created starting entry and if it exists
+ if (nullptr != pImpl->m_pCursorOld)
{
const Point aPnt = rMEvt.GetPosPixel();
SvTreeListEntry* pEntry = GetEntry(aPnt);
- if (pEntry && pEntry->m_Items.size() > 0 && (mnClicksToToggle == 1 || pEntry == pImpl->m_pCursorOld))
+
+ // compare if MouseButtonUp *is* on the same entry, regardless of scrolling
+ // or other things
+ if (pEntry && pEntry->m_Items.size() > 0 && 1 == mnClicksToToggle && pEntry == pImpl->m_pCursorOld)
{
SvLBoxItem* pItem = GetItem(pEntry, aPnt.X());
// if the checkbox button was clicked, that will be toggled later, do not toggle here