mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
Added IndexOf method to TreeView to allow for keyboard context menus
This commit is contained in:
@@ -609,6 +609,29 @@ namespace Terminal.Gui {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>
|
||||
/// Returns the Y coordinate within the <see cref="View.Bounds"/> of the
|
||||
/// tree at which <paramref name="toFind"/> would be displayed or null if
|
||||
/// it is not currently exposed (e.g. its parent is collapsed).
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Note that the returned value can be negative if the TreeView is scrolled
|
||||
/// down and the <paramref name="toFind"/> object is off the top of the view.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="toFind"></param>
|
||||
/// <returns></returns>
|
||||
public int? IndexOf(T toFind)
|
||||
{
|
||||
var idx = BuildLineMap ().IndexOf (o => o.Model.Equals (toFind));
|
||||
|
||||
if (idx == -1)
|
||||
return null;
|
||||
|
||||
return idx - ScrollOffsetVertical;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>Moves the <see cref="SelectedObject"/> to the next item that begins with <paramref name="character"/></para>
|
||||
/// <para>This method will loop back to the start of the tree if reaching the end without finding a match</para>
|
||||
|
||||
Reference in New Issue
Block a user