Allow dropping data outside of item area in wxDataViewCtrl.

Implement this change for the generic and the native GTK versions and document
it.

Closes #16152.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76416 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-04-27 22:41:40 +00:00
parent 555e57912e
commit cbe6495307
5 changed files with 36 additions and 39 deletions

View File

@@ -862,8 +862,8 @@ void MyFrame::OnDropPossible( wxDataViewEvent &event )
{
wxDataViewItem item( event.GetItem() );
// only allow drags for item, not containers
if (m_music_model->IsContainer( item ) )
// only allow drags for item or background, not containers
if ( item.IsOk() && m_music_model->IsContainer( item ) )
event.Veto();
if (event.GetDataFormat() != wxDF_UNICODETEXT)
@@ -875,7 +875,7 @@ void MyFrame::OnDrop( wxDataViewEvent &event )
wxDataViewItem item( event.GetItem() );
// only allow drops for item, not containers
if (m_music_model->IsContainer( item ) )
if ( item.IsOk() && m_music_model->IsContainer( item ) )
{
event.Veto();
return;
@@ -890,7 +890,10 @@ void MyFrame::OnDrop( wxDataViewEvent &event )
wxTextDataObject obj;
obj.SetData( wxDF_UNICODETEXT, event.GetDataSize(), event.GetDataBuffer() );
wxLogMessage( "Text dropped: %s", obj.GetText() );
if ( item.IsOk() )
wxLogMessage( "Text dropped on item %s: %s", m_music_model->GetTitle( item ), obj.GetText() );
else
wxLogMessage( "Text dropped on background: %s", obj.GetText() );
}
#endif // wxUSE_DRAG_AND_DROP