Skip to content

Add more navigation#356

Open
Mangepange wants to merge 1 commit intow-ahmad:mainfrom
Mangepange:feature_348_improved_nav
Open

Add more navigation#356
Mangepange wants to merge 1 commit intow-ahmad:mainfrom
Mangepange:feature_348_improved_nav

Conversation

@Mangepange
Copy link
Copy Markdown

@Mangepange Mangepange commented Apr 28, 2026

Added navigation with

  • Home
  • Home + Ctrl
  • End
  • End + Ctrl
  • PageUp
  • PageDown

This solves #348

The behavior for when using PgUp/PgDn might work in another way, but I ended up just adding/removing one "pagesize" to the current index to keep it simple.

Comment thread src/TableView.cs
}
}

private int CalculateAvailablePageSize()
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add some info comment on this method?

Comment thread src/TableView.cs
Comment on lines +233 to +250
else if (e.Key == VirtualKey.Home)
{
var row = (ctrlKey ? 0 : CurrentCellSlot?.Row) ?? -1;
var column = 0;

var newSlot = new TableViewCellSlot(row, column);
MakeSelection(newSlot, shiftKey);
e.Handled = true;
}
else if (e.Key == VirtualKey.End)
{
var row = (ctrlKey ? _collectionView.Count - 1 : CurrentCellSlot?.Row) ?? -1;
var column = Columns.VisibleColumns.Count - 1;

var newSlot = new TableViewCellSlot(row, column);
MakeSelection(newSlot, shiftKey);
e.Handled = true;
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we merge these two code blocks because they blocks look almost identical, except for lines 235 and 244, and this difference can be managed with a condition.

Comment thread src/TableView.cs
Comment on lines +251 to +277
else if (e.Key == VirtualKey.PageDown)
{
var pageSize = CalculateAvailablePageSize();

var row = (LastSelectionUnit is TableViewSelectionUnit.Row ? CurrentRowIndex : CurrentCellSlot?.Row) ?? -1;
var column = CurrentCellSlot?.Column ?? -1;

var numRows = CollectionView.Count;
var nextRow = Math.Min(numRows - 1, row + pageSize);

var newSlot = new TableViewCellSlot(nextRow, column);
MakeSelection(newSlot, shiftKey);
e.Handled = true;
}
else if (e.Key == VirtualKey.PageUp)
{
var pageSize = CalculateAvailablePageSize();

var row = (LastSelectionUnit is TableViewSelectionUnit.Row ? CurrentRowIndex : CurrentCellSlot?.Row) ?? -1;
var column = CurrentCellSlot?.Column ?? -1;

var nextRow = Math.Max(0, row - pageSize);

var newSlot = new TableViewCellSlot(nextRow, column);
MakeSelection(newSlot, shiftKey);
e.Handled = true;
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these code blocks could be merged as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants