feat: move UIDebug PrintOutObject into Util, add ImGuiHelpers.ClickToCopyText

This commit is contained in:
goat 2021-12-07 21:54:05 +01:00
parent fb0d0de3ad
commit 65d0acaf64
No known key found for this signature in database
GPG key ID: 7773BB5B43BA52E5
3 changed files with 169 additions and 156 deletions

View file

@ -119,5 +119,23 @@ namespace Dalamud.Interface
{
GlobalScale = ImGui.GetIO().FontGlobalScale;
}
/// <summary>
/// Print out text that can be copied when clicked.
/// </summary>
/// <param name="text">The text to show.</param>
/// <param name="textCopy">The text to copy when clicked.</param>
public static void ClickToCopyText(string text, string? textCopy = null)
{
textCopy ??= text;
ImGui.Text($"{text}");
if (ImGui.IsItemHovered())
{
ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
if (textCopy != text) ImGui.SetTooltip(textCopy);
}
if (ImGui.IsItemClicked()) ImGui.SetClipboardText($"{textCopy}");
}
}
}