This site makes extensive use of JavaScript.
Please enable JavaScript in your browser.
Classic Theme
Thottbot Theme
My own tooltip is just almost working
Post Reply
Return to board index
Post by
janniie
For one of my addons I created a tooltip which i fill with :SetHyperlink(link).
I have onw big window, containing up to 20 smaller ones, each representing a spell. I want the tooltip to show, and be filled with the spell, whenever I mouseover one of the small windows. When I mouseover it's filled and shown exactly as I want to. But here starts the problems.
I want the tooltip to hide when I leave each window, so I started by adding :Hide() on each small frames "OnLeave", this hides it but makes it impossible to show again ("OnEnter"). If I remove the hiding, the tooltip changes to the right spells when I mouseover new ones, but once I leave the big frame the tooltip becomes blank from :ClearLines() but keeps following the mouse.
I tried putting the :Hide() on the main frame's "OnLeave". The tooltip just flashes and the dissapear.
It seems like everytime I hide it, I can't show it again.
Is there something special you have to do with tooltips for them to behave themselves, or should I provide my code?
Post by
Neffi
Provide your code. You're definitely hitting a bug somewhere. I'm using :SetHyperlink('spell:#') for my own cooldown display, and a simple :Show() @ OnEnter and :Hide() @ OnLeave functions just as expected.
Also, clarify if you're using your own tooltip frame instead of GameTooltip? If so,
don't
. I personally consider this bad practice. It's pointless to have more than 1 standard tooltip, since you'll only ever be mousing over 1 thing at a time. Having an extra custom tooltip only means more work for you, and more annoyance for users when their tooltip customizations don't apply to yours.
Edit:
Woops
. :Show() @ OnEnter is not correct. Tooltips don't work that way. They work on the basis of ownership. Just replace your :Show() line with
:SetOwner(...)
. This will automatically show it. No special logic when you're done, just :Hide() and the tooltip takes care of the rest. Here's an example from my code mentioned above:
GameTooltip:SetOwner(self,'ANCHOR_CURSOR')
GameTooltip:SetHyperlink(self.link)
Post by
janniie
I was using a tooltip made from the GameTooltipTemplate, but after I did the changes you mentioned, it still doesn't work (With or without the :Show())
edit: for some reason the indents doesn't work... hope you can read it anyway
for i = 1,76 do
f.items = CreateFrame("Button","NewSpell"..i,f)
f.items:SetPoint("TOPLEFT",f,"TOPLEFT",anchor.x,anchor.y)
if mod(i-1,4) == 3 then
anchor.x = 15
anchor.y = anchor.y - 30
else
anchor.x = anchor.x + 83
end
f.items:SetWidth(25)
f.items:SetHeight(25)
f.items:SetHitRectInsets(0, -50, 0, 0)
f.items:SetFrameStrata("HIGH")
f.items.icon = f.items:CreateTexture()
f.items.icon:SetAllPoints()
f.items.text = f.items:CreateFontString(nil,nil,"GameFontNormal")
f.items.text:SetPoint("LEFT",f.items,"RIGHT",3,0)
f.items.highlight = f.items:CreateTexture("OVERLAY")
f.items:EnableMouse(true)
f.items.highlight:SetTexture(1,1,0,0.2)
f.items.highlight:SetHeight(29)
f.items.highlight:SetWidth(78)
f.items.highlight:SetPoint("LEFT",f.items,"LEFT",-3,0)
f.items.highlight:Hide()
f.items:Hide()
f.items:RegisterForClicks("LeftButtonDown","RightButtonDown")
f.items:SetScript("OnEnter",function(self)
self.highlight:Show()
GameTooltip:SetHyperlink(self.link)
GameTooltip:SetOwner(self,"ANCHOR_CURSOR")
GameTooltip:Show()
end)
f.items:SetScript("OnLeave",function(self)
self.highlight:Hide()
GameTooltip:Hide()
end)
f.items:SetScript("OnClick",function(self,button)
if button == "LeftButton" then
AddSpellWatch(self.spell.ID,true)
print("Added "..GetSpellInfo(self.spell.ID).." "..self.spell.cd.." sec")
else
AddSpellWatch(self.spell.ID,false)
print("Removed "..GetSpellInfo(self.spell.ID).." "..self.spell.cd.." sec")
end
UpdateSpells()
end)
end
Post by
Neffi
It could be related to the following errors:
f.items.icon = f.items:CreateTexture() -- you need to pass args, eg (nil,'BORDER')
f.items.text = f.items:CreateFontString(nil,nil,"GameFontNormal") -- you need to pass a draw layer, eg (nil,'ARTWORK','GameFontNormal')
f.items.highlight = f.items:CreateTexture("OVERLAY") -- You're passing OVERLAY as name. Put a nil in front of it.
Also, on .highlight, set the layer as "HIGHLIGHT", not overlay. If you do this, the game-engine takes care of showing/hiding it when you mouseover/mouseout. So you don't need to manually do it @ OnEnter and OnLeave.
Also, :SetOwner() may need to be called before :SetHyperlink(). I'm inclined to say it does, but I don't know for sure.
Post by
janniie
Ok I will test that, thanks :)
Just FYI, if you ommit the layer in CreateFontString() it defaults for "ARTWORK" :) I did miss on the texture though :P
Edit: Thanks alot! Switching the SetOwner and SetHyperlink did the trick :)
Post Reply
You are not logged in. Please
log in
to post a reply or
register
if you don't already have an account.