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
This commit is contained in:
PB
2021-02-28 12:10:30 +01:00
committed by Vadim Zeitlin
parent f6a53b59b2
commit a75aa78263

View File

@@ -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);