DoGridDragEvent error

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
griderror
In need of some credit
In need of some credit
Posts: 4
Joined: Wed Aug 08, 2018 12:22 pm

DoGridDragEvent error

Post by griderror »

I'm using wxWidgets-3.1.1
My grid:

Code: Select all

grid = new wxGrid(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
grid->CreateGrid(10, 10);
When I select 2 or more cells with left mouse button, press right mouse button and drag I got this error from
void wxGrid::DoGridDragEvent(wxMouseEvent& event, const wxGridCellCoords& coords):

Code: Select all

wxASSERT_MSG( !m_winCapture, "shouldn't capture the mouse twice" );
How to solve this issue? I may or may not want to drag data from cells in the future.
catalin
Moderator
Moderator
Posts: 1618
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: DoGridDragEvent error

Post by catalin »

Make sure the mouse is not already captured (even by the same window) when starting a drag.
griderror
In need of some credit
In need of some credit
Posts: 4
Joined: Wed Aug 08, 2018 12:22 pm

Re: DoGridDragEvent error

Post by griderror »

I'm new to wxWidgets so I don't know how to do it. The problem occurs when I press RMB+drag while still holding LMB. I checked

Code: Select all

void MainFrame::OnGridRightClick(wxGridEvent& event) {
	auto* cw = GetCapture();
	if (cw != nullptr) {
		wxMessageBox(cw->GetName(), "Who has the capture?", wxOK | wxICON_INFORMATION);
	}
}
From this I see that GridWindow has capture. With msgbox there is no assertion failure. I suppose I need to somehow release LMB before RMB click. I tried EVT_GRID_CELL_BEGIN_DRAG but not even msgbox pops up. I also tried grid->GetGridWindow()->ReleaseMouse() on RMB but it didn't work.
User avatar
doublemax
Moderator
Moderator
Posts: 19163
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: DoGridDragEvent error

Post by doublemax »

This also happens in the "grid" sample. Please open a bug report at http://trac.wxwidgets.org
Use the source, Luke!