Yes it is,
Code: Select all
Bind(wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, &MainFrame::OnDragFromSampleView, this);
Yes it is,
Code: Select all
Bind(wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, &MainFrame::OnDragFromSampleView, this);
I have as of now 5 event handlers for wxDataViewListCtrl,
Code: Select all
Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, &MainFrame::OnClickSampleView, this, BC_SampleListView);
Bind(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, &MainFrame::OnCheckFavorite, this, BC_SampleListView);
Bind(wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, &MainFrame::OnDragFromSampleView, this);
m_SampleListView->Connect(wxEVT_DROP_FILES, wxDropFilesEventHandler(MainFrame::OnDragAndDropToSampleListView), NULL, this);
Bind(wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, &MainFrame::OnShowSampleListViewContextMenu, this, BC_SampleListView);
I made this small demo program for what I was trying to do, It is doing the exact thing that I mentioned in the previous post.
Code: Select all
void MainFrame::OnDragAndDropToCollectionView(wxDropFilesEvent& event)
{
if (event.GetNumberOfFiles() > 0) // <========
{
.
.
.
}
Code: Select all
void MainFrame::OnDragAndDropToCollectionView(wxDropFilesEvent& event)
{
if (event.GetNumberOfFiles() <= 0) // <========
{
.
.
.
}
The files you sent back, acts the same way for me as before. Also if I don't use m_SampleListView to get the files, it won't detect that I'm dragging more than 1 file, it always says I dragged 1 file. This is why I used this. I copied the exact code you sent me, it says 0 files dragged. For some reason.
What do I need to test the demo program I shared above on windows. I mean how do I set up the environment on windows for building? Will my same meson file work? I have a separate laptop that I can use to test on windows. I eventually want to make my app available on windows as well so I have to do this someday anyway. Maybe then I'll test if it indeed behaves different than what I'm seeing on Linux.doublemax wrote: ↑Tue Jun 01, 2021 8:35 pm I guess the native control under Linux behaves differently than the generic one under Windows. Unfortunately i can only test under Windows.
At least the fact that it's impossible to drag multiple items because a single click clears the selection looks like a bug to me.
I have a small problem, where I check for, if the item on which the file is being dropped is a container or not, I'm calling SetToggleValue(), to toggle the column to true in wxDataViewListCtrl, but it triggers the other handler function that I have for when the column is toggled named OnCheckFavorite(), and results in duplicating the files being dropped. Here is the section from drag and drop handler,
Code: Select all
if(drop_target.IsOk() && m_CollectionView->IsContainer(drop_target))
{
m_SampleListView->SetToggleValue(true, row, 0); // <-----------
m_CollectionView->AppendItem(drop_target, files[i]);
db.UpdateFavoriteColumn(files[i].ToStdString(), 1);
db.UpdateFavoriteFolder(files[i].ToStdString(), folder_name.ToStdString());
}
Code: Select all
wxDataViewItem selected = m_CollectionView->GetSelection();
wxString folder;
if(selected.IsOk() && m_CollectionView->IsContainer(selected))
{
folder = m_CollectionView->GetItemText(selected);
m_CollectionView->AppendItem(selected, selection);
}
else
{
folder = m_CollectionView->GetItemText(favorites_folder);
m_CollectionView->AppendItem(favorites_folder, selection);
}
db.UpdateFavoriteColumn(selection.ToStdString(), 1);
db.UpdateFavoriteFolder(selection.ToStdString(), folder.ToStdString());
I am already checking for duplicates before adding a item, what is happening here, is say I have 3 folders, A, B and C, A is default folder that is there and cannot be deleted, B and C are user created folders. I have set it up as such if user drags and drops a file on empty area in wxDataViewTreeCtrl, it won't let the user add, and if the user toggles the toggle column if no folder is selected, it will go to folder A. But if user drags and drops on folder B or C it also gets added to B/C and A, because it triggers the other method and that folder does not have that file. I cannot add the same file to either A or B after this. This gets fixed when the app is closed and reopened again, as I am storing which folder the file goes to in database so it loads back in that folder when the app is opened again.
Code: Select all
if (found_item.IsOk())
{
wxString msg = wxString::Format("%s already added as favorite.", selection);
wxMessageDialog msgDialog(NULL, msg, "Info", wxOK | wxICON_INFORMATION);
msgDialog.ShowModal();
}
else
{
wxLogDebug("Sample not found adding as fav.");
wxDataViewItem selected = m_CollectionView->GetSelection();
wxString folder;
if(selected.IsOk() && m_CollectionView->IsContainer(selected))
{
folder = m_CollectionView->GetItemText(selected);
m_CollectionView->AppendItem(selected, selection);
}
else
{
folder = m_CollectionView->GetItemText(favorites_folder);
m_CollectionView->AppendItem(favorites_folder, selection);
}
db.UpdateFavoriteColumn(selection.ToStdString(), 1);
db.UpdateFavoriteFolder(selection.ToStdString(), folder.ToStdString());