Skip to content

Commit

Permalink
Ensure column & range selections are updated when shift is used to ex…
Browse files Browse the repository at this point in the history
…tend the active selection region.
  • Loading branch information
anmcgrath committed May 31, 2023
1 parent a14fa9b commit 2e0d684
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/BlazorDatasheet/Datasheet.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions src/BlazorDatasheet/Selecting/Selection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,17 @@ public void Remove(IRegion region)
emitSelectionChange();
}

/// <summary>
/// Extends the active region to the row/col specified
/// </summary>
/// <param name="row"></param>
/// <param name="col"></param>
internal void ExtendTo(int row, int col)
{
ActiveRegion?.ExtendTo(row, col);
emitSelectingChanged();
}

/// <summary>
/// Clears any selections or active selections and sets the selection to the region specified
/// </summary>
Expand Down

0 comments on commit 2e0d684

Please sign in to comment.