2
0
Эх сурвалжийг харах

Added DesiredCursorVisibility to TreeView (#1561)

Thomas Nind 3 жил өмнө
parent
commit
85c74b8357

+ 24 - 0
Terminal.Gui/Views/TreeView.cs

@@ -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>