diff --git a/MLEM.Ui/Elements/Tooltip.cs b/MLEM.Ui/Elements/Tooltip.cs
index b56868a..2a6b9c3 100644
--- a/MLEM.Ui/Elements/Tooltip.cs
+++ b/MLEM.Ui/Elements/Tooltip.cs
@@ -46,22 +46,10 @@ namespace MLEM.Ui.Elements {
if (elementToHover != null) {
elementToHover.OnMouseEnter += element => {
// only display the tooltip if there is anything in it
- if (this.Children.All(c => c.IsHidden))
- return;
- element.System.Add(element.GetType().Name + "Tooltip", this);
- if (this.Delay <= TimeSpan.Zero) {
- this.IsHidden = false;
- this.SnapPositionToMouse();
- } else {
- this.IsHidden = true;
- this.delayCountdown = this.Delay;
- }
- };
- elementToHover.OnMouseExit += element => {
- this.delayCountdown = TimeSpan.Zero;
- if (this.System != null)
- this.System.Remove(this.Root.Name);
+ if (this.Children.Any(c => !c.IsHidden))
+ this.Display(element.System, element.GetType().Name + "Tooltip");
};
+ elementToHover.OnMouseExit += element => this.Remove();
}
}
@@ -111,5 +99,30 @@ namespace MLEM.Ui.Elements {
this.PositionOffset = offset;
}
+ ///
+ /// Adds this tooltip to the given and either displays it directly or starts the timer.
+ ///
+ /// The system to add this tooltip to
+ /// The name that this tooltip should use
+ public void Display(UiSystem system, string name) {
+ system.Add(name, this);
+ if (this.Delay <= TimeSpan.Zero) {
+ this.IsHidden = false;
+ this.SnapPositionToMouse();
+ } else {
+ this.IsHidden = true;
+ this.delayCountdown = this.Delay;
+ }
+ }
+
+ ///
+ /// Removes this tooltip from its and resets the timer, if there is one.
+ ///
+ public void Remove() {
+ this.delayCountdown = TimeSpan.Zero;
+ if (this.System != null)
+ this.System.Remove(this.Root.Name);
+ }
+
}
}
\ No newline at end of file