From 50119da955ca435cd4e87ceaf5594b7c6b3cbc4a Mon Sep 17 00:00:00 2001 From: tznind Date: Sat, 23 Jan 2021 10:51:39 +0000 Subject: [PATCH] Fixed ofY in mouse handler and made ContentHeight real time --- Terminal.Gui/Views/TreeView.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Terminal.Gui/Views/TreeView.cs b/Terminal.Gui/Views/TreeView.cs index 08738b4e2..2f6aa6e52 100644 --- a/Terminal.Gui/Views/TreeView.cs +++ b/Terminal.Gui/Views/TreeView.cs @@ -331,7 +331,7 @@ namespace Terminal.Gui { /// /// The current number of rows in the tree (ignoring the controls bounds) /// - public int ContentHeight { get; private set; } + public int ContentHeight => BuildLineMap().Count(); /// /// Returns the string representation of model objects hosted in the tree. Default implementation is to call @@ -522,8 +522,6 @@ namespace Terminal.Gui { toReturn.AddRange(AddToLineMap(root)); } - ContentHeight = toReturn.Count; - return toReturn.ToArray(); } @@ -610,7 +608,7 @@ namespace Terminal.Gui { var map = BuildLineMap(); - var idx = me.OfY + ScrollOffset; + var idx = me.Y + ScrollOffset; // click is outside any visible nodes if(idx < 0 || idx >= map.Length) { @@ -620,7 +618,7 @@ namespace Terminal.Gui { // The line they clicked on var clickedBranch = map[idx]; - bool isExpandToggleAttempt = clickedBranch.IsHitOnExpandableSymbol(Driver,me.OfX); + bool isExpandToggleAttempt = clickedBranch.IsHitOnExpandableSymbol(Driver,me.X); // If we are already selected (double click) if(Equals(SelectedObject,clickedBranch.Model))