From 2e0d68412cd302a2120f1394a1cf24c571d4bd4f Mon Sep 17 00:00:00 2001 From: anmcgrath Date: Wed, 31 May 2023 11:07:39 +1000 Subject: [PATCH] Ensure column & range selections are updated when shift is used to extend the active selection region. --- src/BlazorDatasheet/Datasheet.razor.cs | 6 +++--- src/BlazorDatasheet/Selecting/Selection.cs | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/BlazorDatasheet/Datasheet.razor.cs b/src/BlazorDatasheet/Datasheet.razor.cs index 815731da..1e898ba2 100644 --- a/src/BlazorDatasheet/Datasheet.razor.cs +++ b/src/BlazorDatasheet/Datasheet.razor.cs @@ -220,7 +220,7 @@ private void HandleCellMouseUp(int row, int col, MouseEventArgs e) private void HandleCellMouseDown(int row, int col, MouseEventArgs e) { if (e.ShiftKey && Sheet?.Selection?.ActiveRegion != null) - Sheet?.Selection?.ActiveRegion.ExtendTo(row, col); + Sheet?.Selection?.ExtendTo(row, col); else { if (!e.MetaKey && !e.CtrlKey) @@ -242,7 +242,7 @@ private void HandleCellMouseDown(int row, int col, MouseEventArgs e) private void HandleColumnHeaderMouseDown(int col, MouseEventArgs e) { if (e.ShiftKey && Sheet?.Selection?.ActiveRegion != null) - Sheet?.Selection?.ActiveRegion.ExtendTo(0, col); + Sheet?.Selection?.ExtendTo(0, col); else { if (!e.MetaKey && !e.CtrlKey) @@ -259,7 +259,7 @@ private void HandleColumnHeaderMouseDown(int col, MouseEventArgs e) private void HandleRowHeaderMouseDown(int row, MouseEventArgs e) { if (e.ShiftKey && Sheet?.Selection?.ActiveRegion != null) - Sheet?.Selection?.ActiveRegion.ExtendTo(row, 0); + Sheet?.Selection?.ExtendTo(row, 0); else { if (!e.MetaKey && !e.CtrlKey) diff --git a/src/BlazorDatasheet/Selecting/Selection.cs b/src/BlazorDatasheet/Selecting/Selection.cs index 6ba192a3..5f1e558e 100644 --- a/src/BlazorDatasheet/Selecting/Selection.cs +++ b/src/BlazorDatasheet/Selecting/Selection.cs @@ -218,6 +218,17 @@ public void Remove(IRegion region) emitSelectionChange(); } + /// + /// Extends the active region to the row/col specified + /// + /// + /// + internal void ExtendTo(int row, int col) + { + ActiveRegion?.ExtendTo(row, col); + emitSelectingChanged(); + } + /// /// Clears any selections or active selections and sets the selection to the region specified ///