Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix home/end, url handler, typing nav, and dependency double click #2727

Merged
merged 1 commit into from
Apr 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions GUI/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ private void MarkAllUpdatesToolButton_Click(object sender, EventArgs e)
if (Main.Instance.configuration.AutoSortByUpdate)
{
// set new sort column
var new_sort_column = ModList.Columns[1];
var new_sort_column = ModList.Columns[UpdateCol.Index];
var current_sort_column = ModList.Columns[configuration.SortByColumnIndex];

// Reset the glyph.
Expand All @@ -573,7 +573,7 @@ private void MarkAllUpdatesToolButton_Click(object sender, EventArgs e)
UpdateFilters(this);

// Select the top row and scroll the list to it.
ModList.CurrentCell = ModList.Rows[0].Cells[1];
ModList.CurrentCell = ModList.Rows[0].Cells[SelectableColumnIndex()];
}

ModList.Refresh();
Expand Down Expand Up @@ -1052,9 +1052,7 @@ private void FocusMod(string key, bool exactMatch, bool showAsFirst = false)
{
match.Selected = true;

// Setting this to the 'Name' cell prevents the checkbox from being toggled
// by pressing 'Space' while the row is not indicated as active.
ModList.CurrentCell = match.Cells[2];
ModList.CurrentCell = match.Cells[SelectableColumnIndex()];
if (showAsFirst)
ModList.FirstDisplayedScrollingRowIndex = match.Index;
}
Expand Down
23 changes: 21 additions & 2 deletions GUI/MainModList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,13 @@ private void ModList_KeyDown(object sender, KeyEventArgs e)
{
case Keys.Home:
// First row.
ModList.CurrentCell = ModList.Rows[0].Cells[2];
ModList.CurrentCell = ModList.Rows[0].Cells[SelectableColumnIndex()];
e.Handled = true;
break;

case Keys.End:
// Last row.
ModList.CurrentCell = ModList.Rows[ModList.Rows.Count - 1].Cells[2];
ModList.CurrentCell = ModList.Rows[ModList.Rows.Count - 1].Cells[SelectableColumnIndex()];
e.Handled = true;
break;

Expand All @@ -450,6 +450,25 @@ private void ModList_KeyDown(object sender, KeyEventArgs e)
}
}

/// <summary>
/// Find a column of the grid that can contain the CurrentCell.
/// Can't be hidden or an exception is thrown.
/// Shouldn't be a checkbox because we don't want the space bar to toggle.
/// </summary>
/// <returns>
/// Index of the column to use.
/// </returns>
private int SelectableColumnIndex()
{
// First try the currently active cell's column
return ModList.CurrentCell?.ColumnIndex
// If there's no currently active cell, use the first visible non-checkbox column
?? ModList.Columns.Cast<DataGridViewColumn>()
.FirstOrDefault(c => c is DataGridViewTextBoxColumn && c.Visible)?.Index
// Otherwise use the Installed checkbox column since it can't be hidden
?? Installed.Index;
}

/// <summary>
/// Called on key press when the mod is focused. Scrolls to the first mod with name
/// beginning with the key pressed. If more than one unique keys are pressed in under
Expand Down