View Single Post
03-26-21, 09:25 AM   #1
MinguasBeef
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: May 2019
Posts: 51
[Classic] Create & show tooltip

I'm working on my own unit frames.

I want to show a tooltip for the buff at index 1 when I mouse over my frame. I am not seeing anything, however.

Wrote up a simple example to see what i'm doing.

Code:
local f = CreateFrame("Frame", "TestFrame", UIParent)
f:SetWidth(100)
f:SetHeight(100)
f:SetPoint("CENTER")
f.texture = f:CreateTexture("Texture", "Background")
f.texture:SetColorTexture(0.03, 0.03, 0.03, 0.8)
f.texture:SetAllPoints(f)

local tt = CreateFrame("GameTooltip", "MyTooltip", UIParent, "GameTooltipTemplate")
tt:SetOwner(f, "ANCHOR_RIGHT")
tt:Hide()
   
f:SetScript("OnEnter", function()
    if (UnitBuff("player", 1)) then
        tt:SetUnitBuff("player", 1)
        tt:Show()
    end
end)
  Reply With Quote