Skip to content

Commit 01767ab

Browse files
committed
feat: The previous attempt to add a tooltip to the category lis...
Automated commit generated by the Nanomite code tool. Prompt: The previous attempt to add a tooltip to the category list in BetterBags (PR #891) didn't work. The user reports no tooltip is appearing. Task: 1. Re-examine `config/categorypane.lua` and how the category list is implemented. 2. Check if the `OnEnter` and `OnLeave` handlers are actually being triggered on the correct frame. 3. Verify if `GameTooltip` is being used correctly in this context (e.g., is it being obscured, or is the frame not mouse-enabled?). 4. Fix the implementation so the toolt...
1 parent 85ade34 commit 01767ab

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

.context/patterns.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,3 +1176,41 @@ return lowColor
11761176
- `util/windowgroup.lua:21,28,33,34,41` - Calls to IsShown(), Hide(), Show()
11771177
- `frames/classic/currency.lua:65-81,168` - Example implementation
11781178
- `frames/themeconfig.lua:98` - Reference implementation with AttachFadeAndSlideLeft
1179+
1180+
## Tooltip API Patterns
1181+
1182+
### Pattern: GameTooltip:SetText vs AddLine Have Different Signatures (alpha param)
1183+
**Problem**: Tooltip text appears off-screen or invisible when using `GameTooltip:SetText()` with word wrap.
1184+
1185+
**Why**: `SetText` and `AddLine` have **different signatures**:
1186+
- `GameTooltip:SetText(text, r, g, b, alpha, textWrap)` — has `alpha` (6 args)
1187+
- `GameTooltip:AddLine(text, r, g, b, textWrap)` — NO alpha (5 args)
1188+
1189+
Passing `true` as the 5th argument to `SetText` sets `alpha=true` (coerced to 1) and leaves `textWrap=nil` (false). Long text without wrapping extends off-screen and is invisible.
1190+
1191+
**Solution Pattern**:
1192+
```lua
1193+
-- BAD: true is interpreted as alpha, not textWrap
1194+
GameTooltip:SetText("Long tooltip text here...", 1, 1, 1, true)
1195+
1196+
-- GOOD: include alpha=1 before textWrap=true
1197+
GameTooltip:SetText("Long tooltip text here...", 1, 1, 1, 1, true)
1198+
1199+
-- AddLine does NOT have alpha:
1200+
GameTooltip:AddLine("Additional line", 1, 1, 1, true) -- correct, 5 args
1201+
```
1202+
1203+
**Full tooltip pattern**:
1204+
```lua
1205+
button:SetScript("OnEnter", function()
1206+
GameTooltip:SetOwner(button, "ANCHOR_RIGHT")
1207+
GameTooltip:SetText("Main title", 1, 1, 1, 1, true) -- r, g, b, alpha, wrap
1208+
GameTooltip:AddLine("Extra info", 0.8, 0.8, 0.8, true) -- r, g, b, wrap (no alpha)
1209+
GameTooltip:Show()
1210+
end)
1211+
button:SetScript("OnLeave", function()
1212+
GameTooltip:Hide()
1213+
end)
1214+
```
1215+
1216+
**When to Apply**: Any use of `GameTooltip:SetText()`. Remember alpha comes before textWrap in SetText but AddLine has no alpha parameter.

0 commit comments

Comments
 (0)