Skip to content

Commit

Permalink
Tooltips now close when associated button is destroyed
Browse files Browse the repository at this point in the history
This fixes some instances of #1
  • Loading branch information
Psychpsyo committed Aug 1, 2022
1 parent cfb6215 commit 9acab3f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Tooltippery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
}
}
}
}
}

0 comments on commit 9acab3f

Please sign in to comment.