diff --git a/Tooltippery.cs b/Tooltippery.cs index b0d9889..2e96df8 100644 --- a/Tooltippery.cs +++ b/Tooltippery.cs @@ -64,7 +64,7 @@ private static string commentLabels(IButton button, ButtonEventData eventData) return null; } - // UIX canvas tooltips + // UIX button tooltips [HarmonyPatch(typeof(Button), "RunHoverEnter")] class ButtonTooltipOpen { @@ -92,5 +92,20 @@ static void Postfix(Button __instance) } } } + + // closes all tooltips for a button when that button gets destroyed. + [HarmonyPatch(typeof(Button), "OnDispose")] + class ButtonTooltipDispose + { + static void Postfix(Button __instance) + { + Tooltip toClose; + while (openTooltips.TryGetValue(__instance, out toClose)) + { + openTooltips.Remove(__instance); + hideTooltip(toClose); + } + } + } } } \ No newline at end of file