Added End and Home keys to the ListView.

This commit is contained in:
BDisp
2020-07-02 12:21:08 +01:00
parent 4262b295d5
commit 996cef2ee4

View File

@@ -346,6 +346,12 @@ namespace Terminal.Gui {
OnOpenSelectedItem ();
break;
case Key.End:
return MoveEnd ();
case Key.Home:
return MoveHome ();
}
return base.ProcessKey (kb);
}
@@ -459,6 +465,38 @@ namespace Terminal.Gui {
return true;
}
/// <summary>
/// Moves the selected item index to the last row.
/// </summary>
/// <returns></returns>
public virtual bool MoveEnd ()
{
if (selected != source.Count - 1) {
selected = source.Count - 1;
top = selected;
OnSelectedChanged ();
SetNeedsDisplay ();
}
return true;
}
/// <summary>
/// Moves the selected item index to the first row.
/// </summary>
/// <returns></returns>
public virtual bool MoveHome ()
{
if (selected != 0) {
selected = 0;
top = selected;
OnSelectedChanged ();
SetNeedsDisplay ();
}
return true;
}
int lastSelectedItem = -1;
/// <summary>