mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Renamed to simply GetObjectOnRow and dropped unused X component
This commit is contained in:
@@ -696,17 +696,17 @@ namespace Terminal.Gui {
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// <remarks>
|
||||
/// </remarks>
|
||||
/// If you have screen coordinates then use <see cref="View.ScreenToView(int, int)"/>
|
||||
/// to translate these into the client area of the <see cref="TreeView{T}"/>.
|
||||
/// </summary>
|
||||
/// <param name="point">Point with the <see cref="View.Bounds"/> of the <see cref="TreeView{T}"/></param>
|
||||
/// <returns></returns>
|
||||
public T GetObjectAtPoint (Point point)
|
||||
/// <param name="row">The row of the <see cref="View.Bounds"/> of the <see cref="TreeView{T}"/></param>
|
||||
/// <returns>The object currently displayed on this row or null</returns>
|
||||
public T GetObjectOnRow (int row)
|
||||
{
|
||||
return HitTest (point.Y)?.Model;
|
||||
return HitTest (row)?.Model;
|
||||
}
|
||||
|
||||
///<inheritdoc/>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user