From a75aa7826301a06c77c71b9f4bf1dc21f0927b98 Mon Sep 17 00:00:00 2001 From: PB Date: Sun, 28 Feb 2021 12:10:30 +0100 Subject: [PATCH] Fix dragging file in DnD sample At least on Microsoft Windows, it is possible to start dragging an unselected wxTreeCtrl item. Therefore, in wxEVT_TREE_BEGIN_DRAG handler do not use the path that is currently selected in the control but the one that is actually being dragged. Closes https://github.com/wxWidgets/wxWidgets/pull/2258 --- samples/dnd/dnd.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/dnd/dnd.cpp b/samples/dnd/dnd.cpp index 2f8e20ff88..f33945a595 100644 --- a/samples/dnd/dnd.cpp +++ b/samples/dnd/dnd.cpp @@ -1270,10 +1270,10 @@ void DnDFrame::OnUsePrimary(wxCommandEvent& event) #if wxUSE_DRAG_AND_DROP -void DnDFrame::OnBeginDrag(wxTreeEvent& WXUNUSED(event)) +void DnDFrame::OnBeginDrag(wxTreeEvent& event) { wxFileDataObject data; - data.AddFile(m_ctrlDir->GetPath()); + data.AddFile(m_ctrlDir->GetPath(event.GetItem())); wxDropSource dragSource(this); dragSource.SetData(data);