Added DesiredCursorVisibility to TreeView (#1561)

This commit is contained in:
Thomas Nind
2022-02-06 22:27:19 +00:00
committed by GitHub
parent aeb02fe8fe
commit 85c74b8357

View File

@@ -203,6 +203,22 @@ namespace Terminal.Gui {
/// <value></value>
public AspectGetterDelegate<T> AspectGetter { get; set; } = (o) => o.ToString () ?? "";
CursorVisibility desiredCursorVisibility = CursorVisibility.Default;
/// <summary>
/// Get / Set the wished cursor when the tree is focused
/// </summary>
public CursorVisibility DesiredCursorVisibility {
get => desiredCursorVisibility;
set {
if (desiredCursorVisibility != value && HasFocus) {
Application.Driver.SetCursorVisibility (value);
}
desiredCursorVisibility = value;
}
}
/// <summary>
/// Creates a new tree view with absolute positioning.
/// Use <see cref="AddObjects(IEnumerable{T})"/> to set set root objects for the tree.
@@ -223,6 +239,14 @@ namespace Terminal.Gui {
TreeBuilder = builder;
}
///<inheritdoc/>
public override bool OnEnter (View view)
{
Application.Driver.SetCursorVisibility (DesiredCursorVisibility);
return base.OnEnter (view);
}
/// <summary>
/// Adds a new root level object unless it is already a root of the tree
/// </summary>