From b6993334344a7c31eb8a1406c80d5ed8703b3757 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 17 Sep 2019 14:06:10 +0200 Subject: [PATCH] added a condition to removechildren --- MLEM.Ui/Elements/Element.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/MLEM.Ui/Elements/Element.cs b/MLEM.Ui/Elements/Element.cs index 47f5ca9..619c053 100644 --- a/MLEM.Ui/Elements/Element.cs +++ b/MLEM.Ui/Elements/Element.cs @@ -178,9 +178,12 @@ namespace MLEM.Ui.Elements { this.SetAreaDirty(); } - public void RemoveChildren() { + public void RemoveChildren(Func condition = null) { for (var i = this.Children.Count - 1; i >= 0; i--) { - this.RemoveChild(this.Children[i]); + var child = this.Children[i]; + if (condition == null || condition(child)) { + this.RemoveChild(child); + } } }