Dalamud/Dalamud/Interface/Internal/Windows/Data/WidgetUtil.cs
Haselnussbomber 58fbff7c56
Update text-related ImGui calls (#2337)
* Update text-related ImGui calls

* Use ImU8String for SafeTextColored

* Restore wrapped calls

* Update MenuItem call

* Use ImGui.Text over ImGui.TextUnformatted

* Add ImGui.TextColoredWrapped

* Obsolete SafeText helpers

* Fix obsoleted calls

* SafeTextColored didn't exist before imgui-bindings

* Remove %% replacements
2025-08-04 15:46:43 -07:00

33 lines
876 B
C#

using Dalamud.Bindings.ImGui;
using Dalamud.Interface.Utility;
namespace Dalamud.Interface.Internal.Windows.Data;
/// <summary>
/// Common utilities used in Widgets.
/// </summary>
internal class WidgetUtil
{
/// <summary>
/// Draws text that can be copied on click.
/// </summary>
/// <param name="text">The text shown and to be copied.</param>
/// <param name="tooltipText">The text in the tooltip.</param>
internal static void DrawCopyableText(string text, string tooltipText = "Copy")
{
ImGui.TextWrapped(text);
if (ImGui.IsItemHovered())
{
ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
ImGui.BeginTooltip();
ImGui.Text(tooltipText);
ImGui.EndTooltip();
}
if (ImGui.IsItemClicked())
{
ImGui.SetClipboardText(text);
}
}
}