From 7deacf3bb930906acdfcd469b617734d092a09bf Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 13 May 2022 22:37:01 +0100 Subject: [PATCH] Renamed to simply GetObjectOnRow and dropped unused X component --- Terminal.Gui/Views/TreeView.cs | 10 +++++----- UICatalog/Scenarios/TreeViewFileSystem.cs | 2 +- UnitTests/TreeViewTests.cs | 22 +++++++++++----------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Terminal.Gui/Views/TreeView.cs b/Terminal.Gui/Views/TreeView.cs index 08ea64b4c..d307d3748 100644 --- a/Terminal.Gui/Views/TreeView.cs +++ b/Terminal.Gui/Views/TreeView.cs @@ -696,17 +696,17 @@ namespace Terminal.Gui { /// /// Returns the object in the tree list that is currently visible - /// at the provided col/row. Returns null if no object is at that location. + /// at the provided row. Returns null if no object is at that location. /// /// /// If you have screen coordinates then use /// to translate these into the client area of the . /// - /// Point with the of the - /// - public T GetObjectAtPoint (Point point) + /// The row of the of the + /// The object currently displayed on this row or null + public T GetObjectOnRow (int row) { - return HitTest (point.Y)?.Model; + return HitTest (row)?.Model; } /// diff --git a/UICatalog/Scenarios/TreeViewFileSystem.cs b/UICatalog/Scenarios/TreeViewFileSystem.cs index a5bbf6c76..65ea36566 100644 --- a/UICatalog/Scenarios/TreeViewFileSystem.cs +++ b/UICatalog/Scenarios/TreeViewFileSystem.cs @@ -118,7 +118,7 @@ namespace UICatalog.Scenarios { // if user right clicks if (obj.MouseEvent.Flags.HasFlag(MouseFlags.Button3Clicked)) { - var rightClicked = treeViewFiles.GetObjectAtPoint (new Point (obj.MouseEvent.X, obj.MouseEvent.Y)); + var rightClicked = treeViewFiles.GetObjectOnRow ( obj.MouseEvent.Y); // nothing was clicked if (rightClicked == null) diff --git a/UnitTests/TreeViewTests.cs b/UnitTests/TreeViewTests.cs index bb04122cc..c14cebd51 100644 --- a/UnitTests/TreeViewTests.cs +++ b/UnitTests/TreeViewTests.cs @@ -721,7 +721,7 @@ namespace Terminal.Gui.Views { } [Fact, AutoInitShutdown] - public void TestGetObjectAtPoint () + public void TestGetObjectOnRow () { var tv = new TreeView { Width = 20, Height = 10 }; @@ -746,11 +746,11 @@ namespace Terminal.Gui.Views { └─pink ", output); - Assert.Same (n1, tv.GetObjectAtPoint (new Point (0, 0))); - Assert.Same (n1_1, tv.GetObjectAtPoint (new Point (0, 1))); - Assert.Same (n1_2, tv.GetObjectAtPoint (new Point (0, 2))); - Assert.Same (n2, tv.GetObjectAtPoint (new Point (0, 3))); - Assert.Null (tv.GetObjectAtPoint (new Point (0, 4))); + Assert.Same (n1, tv.GetObjectOnRow (0)); + Assert.Same (n1_1, tv.GetObjectOnRow (1)); + Assert.Same (n1_2, tv.GetObjectOnRow (2)); + Assert.Same (n2, tv.GetObjectOnRow (3)); + Assert.Null (tv.GetObjectOnRow (4)); tv.Collapse (n1); @@ -762,11 +762,11 @@ namespace Terminal.Gui.Views { └─pink ", output); - Assert.Same (n1, tv.GetObjectAtPoint (new Point (0, 0))); - Assert.Same (n2, tv.GetObjectAtPoint (new Point (0, 1))); - Assert.Null (tv.GetObjectAtPoint (new Point (0, 2))); - Assert.Null (tv.GetObjectAtPoint (new Point (0, 3))); - Assert.Null (tv.GetObjectAtPoint (new Point (0, 4))); + Assert.Same (n1, tv.GetObjectOnRow (0)); + Assert.Same (n2, tv.GetObjectOnRow (1)); + Assert.Null (tv.GetObjectOnRow (2)); + Assert.Null (tv.GetObjectOnRow (3)); + Assert.Null (tv.GetObjectOnRow (4)); } [Fact, AutoInitShutdown]