|
@@ -124,6 +124,16 @@ namespace Terminal.Gui {
|
|
|
|
|
|
TextFormatter viewText;
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Event fired when a subview is being added to this view.
|
|
|
+ /// </summary>
|
|
|
+ public Action<View> Added;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Event fired when a subview is being removed from this view.
|
|
|
+ /// </summary>
|
|
|
+ public Action<View> Removed;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Event fired when the view gets focus.
|
|
|
/// </summary>
|
|
@@ -614,6 +624,7 @@ namespace Terminal.Gui {
|
|
|
subviews.Add (view);
|
|
|
tabIndexes.Add (view);
|
|
|
view.container = this;
|
|
|
+ OnAdded (view);
|
|
|
if (view.CanFocus) {
|
|
|
CanFocus = true;
|
|
|
view.tabIndex = tabIndexes.IndexOf (view);
|
|
@@ -668,6 +679,7 @@ namespace Terminal.Gui {
|
|
|
subviews.Remove (view);
|
|
|
tabIndexes.Remove (view);
|
|
|
view.container = null;
|
|
|
+ OnRemoved (view);
|
|
|
view.tabIndex = -1;
|
|
|
if (subviews.Count < 1)
|
|
|
this.CanFocus = false;
|
|
@@ -1010,6 +1022,24 @@ namespace Terminal.Gui {
|
|
|
public View View { get; set; }
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Method invoked when a subview is being added to this view.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="view">The subview being added.</param>
|
|
|
+ public virtual void OnAdded (View view)
|
|
|
+ {
|
|
|
+ view.Added?.Invoke (this);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Method invoked when a subview is being removed from this view.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="view">The subview being removed.</param>
|
|
|
+ public virtual void OnRemoved (View view)
|
|
|
+ {
|
|
|
+ view.Removed?.Invoke (this);
|
|
|
+ }
|
|
|
+
|
|
|
/// <inheritdoc/>
|
|
|
public override bool OnEnter (View view)
|
|
|
{
|