From 63d2353694db7c0311230d458efce0dfcb3d6f72 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 3 May 2022 20:10:26 +0200 Subject: [PATCH] Improved ElementHelper.AddTooltip overloads --- CHANGELOG.md | 1 + MLEM.Ui/Elements/ElementHelper.cs | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac560db..7f00a6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ Improvements - Allow Tooltip to manage more than one paragraph and make it easier to add new lines - Allow adding dropdown elements at a specified index - Turned Tooltip paragraph styling into style properties +- Improved ElementHelper.AddTooltip overloads Fixes - Fixed auto-nav tooltip displaying on the selected element even when not in auto-nav mode diff --git a/MLEM.Ui/Elements/ElementHelper.cs b/MLEM.Ui/Elements/ElementHelper.cs index bcaecb8..426e1e4 100644 --- a/MLEM.Ui/Elements/ElementHelper.cs +++ b/MLEM.Ui/Elements/ElementHelper.cs @@ -184,7 +184,7 @@ namespace MLEM.Ui.Elements { /// The text to display on the tooltip /// The created tooltip instance public static Tooltip AddTooltip(this Element element, Paragraph.TextCallback textCallback) { - return new Tooltip(textCallback, element); + return element.AddTooltip(new Tooltip(textCallback)); } /// @@ -194,7 +194,18 @@ namespace MLEM.Ui.Elements { /// The text to display on the tooltip /// The created tooltip instance public static Tooltip AddTooltip(this Element element, string text) { - return new Tooltip(text, element); + return element.AddTooltip(new Tooltip(text)); + } + + /// + /// Adds the given to the given element + /// + /// The element to add the tooltip to + /// The tooltip to add + /// The passed tooltip, for chaining + public static Tooltip AddTooltip(this Element element, Tooltip tooltip) { + tooltip.AddToElement(element); + return tooltip; } }