浏览代码

View.Remove returns added view

Tig 1 年之前
父节点
当前提交
f99a744ef8

+ 4 - 2
Terminal.Gui/View/ViewSubViews.cs

@@ -209,11 +209,11 @@ public partial class View
     ///         lifecycle to be transferred to the caller; the caller muse call <see cref="Dispose"/>.
     ///     </para>
     /// </remarks>
-    public virtual void Remove (View view)
+    public virtual View Remove (View view)
     {
         if (view is null || _subviews is null)
         {
-            return;
+            return view;
         }
 
         Rectangle touched = view.Frame;
@@ -238,6 +238,8 @@ public partial class View
         {
             Focused = null;
         }
+
+        return view;
     }
 
     /// <summary>

+ 3 - 1
Terminal.Gui/Views/Bar.cs

@@ -67,10 +67,12 @@ public class Bar : View
     }
 
     /// <inheritdoc />
-    public override void Remove (View view)
+    public override View Remove (View view)
     {
         base.Remove (view);
         AdjustSubviewBorders ();
+
+        return view;
     }
 
 

+ 4 - 2
Terminal.Gui/Views/ScrollView.cs

@@ -457,11 +457,11 @@ public class ScrollView : View
 
     /// <summary>Removes the view from the scrollview.</summary>
     /// <param name="view">The view to remove from the scrollview.</param>
-    public override void Remove (View view)
+    public override View Remove (View view)
     {
         if (view is null)
         {
-            return;
+            return view;
         }
 
         SetNeedsDisplay ();
@@ -480,6 +480,8 @@ public class ScrollView : View
         {
             CanFocus = false;
         }
+
+        return view;
     }
 
     /// <summary>Removes all widgets from this container.</summary>

+ 2 - 2
Terminal.Gui/Views/Toplevel.cs

@@ -451,14 +451,14 @@ public partial class Toplevel : View
     public event EventHandler Ready;
 
     /// <inheritdoc/>
-    public override void Remove (View view)
+    public override View Remove (View view)
     {
         if (this is Toplevel { MenuBar: { } })
         {
             RemoveMenuStatusBar (view);
         }
 
-        base.Remove (view);
+        return base.Remove (view);
     }
 
     /// <inheritdoc/>

+ 4 - 2
Terminal.Gui/Views/Wizard/WizardStep.cs

@@ -142,11 +142,11 @@ public class WizardStep : FrameView
 
     /// <summary>Removes a <see cref="View"/> from <see cref="WizardStep"/>.</summary>
     /// <remarks></remarks>
-    public override void Remove (View view)
+    public override View Remove (View view)
     {
         if (view is null)
         {
-            return;
+            return view;
         }
 
         SetNeedsDisplay ();
@@ -167,6 +167,8 @@ public class WizardStep : FrameView
         }
 
         ShowHide ();
+
+        return view;
     }
 
     /// <summary>Removes all <see cref="View"/>s from the <see cref="WizardStep"/>.</summary>