From 51ea80b70190246bf3a619ea98383c7b784e74b5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 15 Apr 2020 00:03:37 +0200 Subject: [PATCH] Allow selecting rows/columns in row-or-column selection mode Don't blankly forbid selecting any blocks at all in this mode, this didn't really make any sense. Moreover, SelectBlock() not doing anything prevented wxGrid code handling {Ctrl,Shift}-Space from doing anything in this mode and, worse, broke the logic of DeselectBlock() which relied on using SelectBlock() to select the remaining parts of the selection, so this commit fixes using Ctrl-click for deselecting rows or columns in this selection mode, which was previously completely broken. --- src/generic/gridsel.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/generic/gridsel.cpp b/src/generic/gridsel.cpp index 7f382f3715..97aeee4f50 100644 --- a/src/generic/gridsel.cpp +++ b/src/generic/gridsel.cpp @@ -186,9 +186,16 @@ void wxGridSelection::SelectBlock( int topRow, int leftCol, break; case wxGrid::wxGridSelectRowsOrColumns: - // block selection doesn't make sense for this mode, we could only - // select the entire grid but this wouldn't be useful - allowed = 0; + // Arbitrary block selection doesn't make sense for this mode, as + // we could only select the entire grid, which wouldn't be useful, + // but we do allow selecting blocks that are already composed of + // only rows or only columns. + if ( topRow == 0 && bottomRow == m_grid->GetNumberRows() - 1 ) + allowed = 1; + else if ( leftCol == 0 && rightCol == m_grid->GetNumberCols() - 1 ) + allowed = 1; + else + allowed = 0; break; }