From 2cc77f42cd02f670391eff94564b4b1248d792ac Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 8 Jun 2021 21:36:42 +0200 Subject: [PATCH] added events for when a root element is added or removed from a ui --- MLEM.Ui/UiSystem.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/MLEM.Ui/UiSystem.cs b/MLEM.Ui/UiSystem.cs index 8439b72..6caceaa 100644 --- a/MLEM.Ui/UiSystem.cs +++ b/MLEM.Ui/UiSystem.cs @@ -268,6 +268,7 @@ namespace MLEM.Ui { e.SetAreaDirty(); }); this.OnRootAdded?.Invoke(root); + root.OnAddedToUi?.Invoke(this); this.SortRoots(); return root; } @@ -289,6 +290,7 @@ namespace MLEM.Ui { e.SetAreaDirty(); }); this.OnRootRemoved?.Invoke(root); + root.OnRemovedFromUi?.Invoke(this); } /// @@ -417,9 +419,17 @@ namespace MLEM.Ui { /// public Element.GenericCallback OnElementAdded; /// - /// Even that is invoked when a is removed rom this root element of any of its children. + /// Event that is invoked when a is removed rom this root element of any of its children. /// public Element.GenericCallback OnElementRemoved; + /// + /// Event that is invoked when this gets added to a in + /// + public Action OnAddedToUi; + /// + /// Event that is invoked when this gets removed from a in + /// + public Action OnRemovedFromUi; internal RootElement(string name, Element element, UiSystem system) { this.Name = name;