Skip to content

tooltips

CyanideX edited this page Aug 14, 2026 · 2 revisions

Tooltips

Hover tooltips for ImGui elements with styling variants, keybind hints, and multi-line support.

The module is exposed as wu.Tooltips.

Quick Start

local wu = GetMod("WindowUtils")
local tips = wu.Tooltips

ImGui.Button("Save")
tips.Show("Save current settings")

ImGui.Button("Delete")
tips.ShowDanger("This cannot be undone!")

All tooltip functions check ImGui.IsItemHovered() internally - call them immediately after the ImGui element they describe.

tooltipsEnabled setting: The WindowUtils "Show Tooltips" checkbox controls whether bound controls (sliders, checkboxes, combos, etc.) show their tooltips within WU's own UI. This setting does not affect consumer mods - tooltips.Show always renders for any caller. The alwaysShowTooltip = true opt on controls bypasses the toggle for individual controls that must always show their tooltip.

Configuration

setDefaultWidthPct(pct)

Set the default tooltip max width as a percentage of screen width. Show and ShowAlways use this unless overridden per-call. Default is 15%, and WindowUtils overwrites it at init with the user's tooltipMaxWidthPct setting, so calling this yourself can be undone by a settings change.

The width is applied against the normalized (1080p-relative) screen width, not raw pixels. It has no effect on the table form of Show, on ShowWrapped (which takes pixels), or on any styled variant.

tips.setDefaultWidthPct(20)  -- 20% of screen width

API Reference

Basic Tooltips

Show(tooltip, widthPct?)

Shows a tooltip on hover. Accepts a plain string or a structured {title, bullets} table. nil is a no-op. Always renders for any caller - consumer mods are never affected by WU's tooltipsEnabled setting.

Parameter Type Description
tooltip string|table|nil Plain string for text, or {title, bullets} table for bullet format. nil = no-op.
widthPct number Optional max width as screen-width percentage (string mode only). Pass 0 to disable wrapping.

String format: Auto-wraps at the configured max width (default 15% of screen width). Pass widthPct = 0 to render a single unwrapped line.

Table format: {title, bullets} renders a titled bullet-point tooltip. tooltip[1] is a plain text header followed by a separator, tooltip[2] is an array rendered as ImGui.BulletText items. Both elements are optional. widthPct is ignored in table mode - break long strings yourself or use string mode for lengthy content.

-- Plain text
tips.Show("Save current settings")

-- With explicit width (20% of screen)
tips.Show("Save current settings", 20)

-- No wrapping
tips.Show("Save current settings", 0)

-- Structured bullets
tips.Show({
    "controls.SectionHeader(label, before, after, iconGlyph?, tooltip?, opts?)",
    { "label  - section title text", "before  - pixels above separator", "after  - pixels below label" },
})

Conditional tooltips: Show does not have a built-in condition parameter. Call it inside an if block:

if someCondition then
    tips.Show("Only shown when condition is true")
end

alwaysShowTooltip on control opts: Controls that accept a tooltip opt also accept alwaysShowTooltip = true, which bypasses the WU tooltipsEnabled setting for that specific control. By default, bound controls respect the setting; alwaysShowTooltip = true opts them out.

ctx:Checkbox("Enable Feature", "myKey", {
    tooltip = "Always visible regardless of tooltip setting",
    alwaysShowTooltip = true,
})

ShowAlways(text, widthPct?) (deprecated)

Deprecated. Use tooltips.Show(text, widthPct, true) instead. Calling this function prints a deprecation warning to the console.

Equivalent to Show(text, widthPct, true) - renders on hover regardless of tooltipsEnabled.

ShowWrapped(text, maxWidth?)

Shows a tooltip on hover with text wrapping at a fixed pixel width. Unlike Show's widthPct (screen-relative percentage), this takes an absolute pixel value. Respects the tooltipsEnabled setting.

Parameter Type Default Description
text string Tooltip text.
maxWidth number 300 Wrap width in pixels.
ImGui.Button("Details")
tips.ShowWrapped("A longer description that wraps at exactly 250 pixels wide.", 250)

Styled Tooltips

ShowTitled(title, description?)

Tooltip with a title line, separator, and grey description text. The description wraps at a fixed 300 pixels; the title does not wrap. ShowHelp and ShowWithHint use the same fixed 300 pixel wrap for their body text.

ImGui.Button("Export")
tips.ShowTitled("Export Settings", "Saves all presets to a JSON file in the mod folder.")

ShowColored(text, r, g, b, a?)

Tooltip with custom text color (RGBA 0-1, alpha defaults to 1).

ShowMuted(text) / ShowSuccess(text) / ShowDanger(text) / ShowWarning(text)

Pre-colored tooltip shortcuts:

Function Color
ShowMuted Grey (0.6, 0.6, 0.6)
ShowSuccess Green (0, 1, 0.7)
ShowDanger Red (1, 0.3, 0.3)
ShowWarning Yellow (1, 0.8, 0)

Info & Help Tooltips

ShowHelp(text)

Tooltip with a blue [?] prefix and wrapped text. Good for explaining settings.

ImGui.Checkbox("Auto-save", autoSave)
tips.ShowHelp("Automatically saves settings when changes are made.")

ShowKeybind(action, keybind)

Tooltip showing an action with its keybind in grey brackets.

ImGui.Button("Reset")
tips.ShowKeybind("Reset to defaults", "Right-click")

ShowWithHint(text, hint?)

Tooltip with main text, separator, and grey hint text.

ImGui.SliderFloat("##vol", volume, 0, 1)
tips.ShowWithHint("Volume", "Right-click to reset")

Multi-line Tooltips

ShowLines(lines)

Tooltip with multiple text lines.

ImGui.Button("Info")
tips.ShowLines({"Line 1", "Line 2", "Line 3"})

ShowBullets(title?, bullets)

Tooltip with optional title and bullet points.

ImGui.Button("Features")
tips.ShowBullets("Supported modes:", {"Standard", "Night Vision", "Thermal"})

Color Tooltips

ShowColor(r, g, b, displayName, hex?)

Shows a color tooltip with a small swatch preview, display name, and optional hex code.

Parameter Type Description
r number Red channel (0.0-1.0)
g number Green channel (0.0-1.0)
b number Blue channel (0.0-1.0)
displayName string Color display name shown next to the swatch
hex string|nil Optional hex string shown as #RRGGBB below the name. Omitted if nil.
ImGui.Button("##color_preview")
tips.ShowColor(1.0, 0.5, 0.0, "Sunset Orange", "FF8000")

-- Without hex code
ImGui.Button("##swatch")
tips.ShowColor(0.2, 0.6, 1.0, "Sky Blue")

Clone this wiki locally