From ede67d4b24341d42dc042b53781621bcc481f109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Pinkava?= Date: Thu, 12 Sep 2024 09:08:50 +0200 Subject: [PATCH] GUI: Fix tree visibility click when a tree item gets collapsed The tree can change shape during handling the mousePressEvent() event, because some part of the tree can be (un)folded. This might lead to shift of the three (up or down). The position of items in tree change relatively to the position of mouse (which stays in place). If the visibility click is handled after mousePressEvent, the shift in position can lead to cursor beeing over visibility icon and the click is handled like if the visibility icon vas clicked, which is unexpected. Handling the visibility click first fixes this. The setAccepted(true), was removed, it is left to the subroutine to set it. --- src/Gui/Tree.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 57f389984b..01d39314ff 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -1677,10 +1677,6 @@ void TreeWidget::keyPressEvent(QKeyEvent* event) void TreeWidget::mousePressEvent(QMouseEvent* event) { - QTreeWidget::mousePressEvent(event); - - // Handle the visibility icon after the normal event processing to not interfere with - // the selection logic. if (isVisibilityIconEnabled()) { QTreeWidgetItem* item = itemAt(event->pos()); if (item && item->type() == TreeWidget::ObjectType && event->button() == Qt::LeftButton) { @@ -1728,12 +1724,11 @@ void TreeWidget::mousePressEvent(QMouseEvent* event) visible = obj->Visibility.getValue(); obj->Visibility.setValue(!visible); } - - event->setAccepted(true); - return; } } } + + QTreeWidget::mousePressEvent(event); } void TreeWidget::mouseDoubleClickEvent(QMouseEvent* event)