Cancel any edit in progress when wxTreeCtrl is scrolled

Otherwise the editor could be scrolled out of view, confusing the user.

Closes https://github.com/wxWidgets/wxWidgets/pull/1522
This commit is contained in:
Matthew Griffin 2019-09-02 09:24:50 +01:00 committed by Vadim Zeitlin
parent 8c18ee8c25
commit 337644f702

View File

@ -23,6 +23,7 @@
#include <QtWidgets/QTreeWidget>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QScrollBar>
#include <QtGui/QPainter>
namespace
@ -142,6 +143,8 @@ public:
this, &wxQTreeWidget::OnItemCollapsed);
connect(this, &QTreeWidget::itemExpanded,
this, &wxQTreeWidget::OnItemExpanded);
connect(verticalScrollBar(), &QScrollBar::valueChanged,
this, &wxQTreeWidget::OnTreeScrolled);
setItemDelegate(&m_item_delegate);
setDragEnabled(true);
@ -438,6 +441,12 @@ private:
EmitEvent(expandedEvent);
}
void OnTreeScrolled(int)
{
if ( GetEditControl() != NULL )
closeEditor(GetEditControl()->GetHandle(), QAbstractItemDelegate::RevertModelCache);
}
void tryStartDrag(const QMouseEvent *event)
{
wxEventType command = event->buttons() & Qt::RightButton