i am quite new to develop own addons and the few tutorials that are out there let a few questions open. maybe you can help:
i am trying to create a simple tooltip when mouse hovers a frame. i already got:
Code:
function showtooltip()
local testtip = CreateFrame("GameTooltip", "ToolTipName") -- Where do i need the ToolTipName for example? Is it even neccessary to declare?
testtip:SetFrameStrata("TOOLTIP")
testtip:SetClampedToScreen(true)
testtip:SetOwner(f, "ANCHOR_CURSOR")
testtip:SetText("tooltipText", 1, 1, 1) -- Whats the difference between SetText and Addline?
testtip:AddLine("tooltipText", 1, 1, 1)
testtip:Show()
end
f = CreateFrame("Frame",nil,UIParent)
f:SetFrameStrata("BACKGROUND")
f:SetWidth(500)
f:SetHeight(500)
f:SetScript("OnEnter", showtooltip)
t = f:CreateTexture(nil,"BACKGROUND")
t:SetTexture(1, 1, 1, 1)
t:SetAllPoints(f)
f.texture = t
f:SetPoint("CENTER",0,0)
f:Show()
the frame with the layer shows up ingame properly, but the tooltip hover isnt working. no error messages are shown.
thnx for your help,
peter|||A couple of things:
You dont actually call the tooltip function, so it is never executed - bind it to a mouseover instead of OnEnter. You could test if the function is working by simply typing this in-game
Code:
/script showtooltip()
SetText - changes the current text if the object already has a text area
AddLine - adds an additional line to a tooltip, this is probably the one you want.
You need to prefix your function, or declare it as local function.
't', 'f' and 'testtip' should also be prefixed, I wouldnt bother declaring these as locals until you have it working.|||Try :
Code:
f:EnableMouse(true)
before the "OnEnter" SetScript
No comments:
Post a Comment