From 408ebfd253144ef3535932314a42fe34256d4a56 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 21 Aug 2020 15:54:47 +0200 Subject: [PATCH] Capture mouse while selecting rows/columns too Change the logic in ChangeCursorMode() to explicitly exclude the modes for which the mouse should not be captured, as CaptureMouse() should be called in most cases (and ideally for all of them in the future) and do capture it for WXGRID_CURSOR_SELECT_{ROW,COL} too, if only to be notified about mouse capture loss. --- src/generic/grid.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 2e8b67cb67..93a4d4764f 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -4453,19 +4453,24 @@ void wxGrid::ChangeCursorMode(CursorMode mode, break; case WXGRID_CURSOR_MOVE_COL: + // Currently we don't capture mouse when moving columns, which is + // almost certainly wrong. + captureMouse = false; win->SetCursor( wxCursor(wxCURSOR_HAND) ); break; - default: + case WXGRID_CURSOR_SELECT_CELL: + // Mouse is captured in ProcessGridCellMouseEvent() in this mode. + captureMouse = false; + wxFALLTHROUGH; + + case WXGRID_CURSOR_SELECT_ROW: + case WXGRID_CURSOR_SELECT_COL: win->SetCursor( *wxSTANDARD_CURSOR ); break; } - // we need to capture mouse when resizing - bool resize = m_cursorMode == WXGRID_CURSOR_RESIZE_ROW || - m_cursorMode == WXGRID_CURSOR_RESIZE_COL; - - if ( captureMouse && resize ) + if ( captureMouse ) { win->CaptureMouse(); m_winCapture = win;