From 53972b17ee702f8dbd0c2fee998bdecbb4f0bdd3 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 17 Aug 2018 00:28:21 +0200 Subject: [PATCH] Add helper wxGrid::DoAfterDraggingEnd() function No real changes, just refactor the code to extract the part of CancelMouseCapture() which can be useful not only when the mouse capture is lost unexpectedly, but also when we release it of our own volition, into a separate function. --- include/wx/generic/grid.h | 4 ++++ src/generic/grid.cpp | 17 +++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index c1adbb0b24..b01c6b4e54 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -2218,6 +2218,10 @@ private: // SetColPos() and ResetColPos()) void RefreshAfterColPosChange(); + // reset the variables used during dragging operations after it ended + // because we lost mouse capture + void DoAfterDraggingEnd(); + // return the position (not index) of the column at the given logical pixel // position diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index f5bd9466a5..c3ab7f0594 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -3846,18 +3846,23 @@ void wxGrid::CancelMouseCapture() // cancel operation currently in progress, whatever it is if ( m_winCapture ) { - m_isDragging = false; - m_startDragPos = wxDefaultPosition; - - m_cursorMode = WXGRID_CURSOR_SELECT_CELL; - m_winCapture->SetCursor( *wxSTANDARD_CURSOR ); - m_winCapture = NULL; + DoAfterDraggingEnd(); // remove traces of whatever we drew on screen Refresh(); } } +void wxGrid::DoAfterDraggingEnd() +{ + m_isDragging = false; + m_startDragPos = wxDefaultPosition; + + m_cursorMode = WXGRID_CURSOR_SELECT_CELL; + m_winCapture->SetCursor( *wxSTANDARD_CURSOR ); + m_winCapture = NULL; +} + void wxGrid::ChangeCursorMode(CursorMode mode, wxWindow *win, bool captureMouse)