diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index d4e403e8eb..d753161100 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -2325,13 +2325,13 @@ protected: // this function is called to extend the block being currently selected // from mouse and keyboard event handlers - void UpdateBlockBeingSelected(int topRow, int leftCol, - int bottomRow, int rightCol); + void UpdateBlockBeingSelected(int blockStartRow, int blockStartCol, + int blockEndRow, int blockEndCol); - void UpdateBlockBeingSelected(const wxGridCellCoords& topLeft, - const wxGridCellCoords& bottomRight) - { UpdateBlockBeingSelected(topLeft.GetRow(), topLeft.GetCol(), - bottomRight.GetRow(), bottomRight.GetCol()); } + void UpdateBlockBeingSelected(const wxGridCellCoords& blockStart, + const wxGridCellCoords& blockEnd) + { UpdateBlockBeingSelected(blockStart.GetRow(), blockStart.GetCol(), + blockEnd.GetRow(), blockEnd.GetCol()); } virtual bool ShouldScrollToChildOnFocus(wxWindow* WXUNUSED(win)) wxOVERRIDE { return false; } diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index c1dbb96548..97a493056e 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -5822,11 +5822,16 @@ bool wxGrid::SetCurrentCell( const wxGridCellCoords& coords ) } void -wxGrid::UpdateBlockBeingSelected(int topRow, int leftCol, - int bottomRow, int rightCol) +wxGrid::UpdateBlockBeingSelected(int blockStartRow, int blockStartCol, + int blockEndRow, int blockEndCol) { + m_selectedBlockCorner = wxGridCellCoords(blockEndRow, blockEndCol); MakeCellVisible(m_selectedBlockCorner); - m_selectedBlockCorner = wxGridCellCoords(bottomRow, rightCol); + + int topRow = wxMin(blockStartRow, blockEndRow); + int leftCol = wxMin(blockStartCol, blockEndCol); + int bottomRow = wxMax(blockStartRow, blockEndRow); + int rightCol = wxMax(blockStartCol, blockEndCol); if ( m_selection ) { @@ -5864,9 +5869,6 @@ wxGrid::UpdateBlockBeingSelected(int topRow, int leftCol, } } - EnsureFirstLessThanSecond(topRow, bottomRow); - EnsureFirstLessThanSecond(leftCol, rightCol); - wxGridCellCoords updateTopLeft = wxGridCellCoords(topRow, leftCol), updateBottomRight = wxGridCellCoords(bottomRow, rightCol);