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.
This commit is contained in:
Vadim Zeitlin
2018-08-17 00:28:21 +02:00
parent a8448b084c
commit 53972b17ee
2 changed files with 15 additions and 6 deletions

View File

@@ -2218,6 +2218,10 @@ private:
// SetColPos() and ResetColPos()) // SetColPos() and ResetColPos())
void RefreshAfterColPosChange(); 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 // return the position (not index) of the column at the given logical pixel
// position // position

View File

@@ -3846,18 +3846,23 @@ void wxGrid::CancelMouseCapture()
// cancel operation currently in progress, whatever it is // cancel operation currently in progress, whatever it is
if ( m_winCapture ) if ( m_winCapture )
{ {
m_isDragging = false; DoAfterDraggingEnd();
m_startDragPos = wxDefaultPosition;
m_cursorMode = WXGRID_CURSOR_SELECT_CELL;
m_winCapture->SetCursor( *wxSTANDARD_CURSOR );
m_winCapture = NULL;
// remove traces of whatever we drew on screen // remove traces of whatever we drew on screen
Refresh(); 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, void wxGrid::ChangeCursorMode(CursorMode mode,
wxWindow *win, wxWindow *win,
bool captureMouse) bool captureMouse)