Merge pull request #724 from BDisp/added-removing-view-events

Fixes #723 Views now are notified when they are added or removing.
This commit is contained in:
Charlie Kindel
2020-07-06 07:58:05 -07:00
committed by GitHub
2 changed files with 51 additions and 0 deletions

View File

@@ -135,5 +135,26 @@ namespace Terminal.Gui {
sub2.Width = Dim.Width (sub2);
Assert.Throws<InvalidOperationException> (() => root.LayoutSubviews ());
}
[Fact]
public void Added_Removing ()
{
var v = new View (new Rect (0, 0, 10, 24));
var t = new View ();
v.Added += (View e) => {
Assert.True (v.SuperView == e);
};
v.Removed += (View e) => {
Assert.True (v.SuperView == null);
};
t.Add (v);
Assert.True (t.Subviews.Count == 1);
t.Remove (v);
Assert.True (t.Subviews.Count == 0);
}
}
}