12.07.2015 Views

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 12 ■ Interacting with Widgets 211if entry.count > 1 thenbutton.count:SetText(entry.count)button.count:Show()elsebutton.count:Hide()endif entry.quality > 1 thenbutton.glow:SetVertexColor(GetItemQualityColor(entry.quality))button.glow:Show()elsebutton.glow:Hide()endbutton:Show()elsebutton.link = nilbutton:Hide()endendDuring the iteration <strong>of</strong> the loop, you just update the link key in the frametable using the link stored in the item entry. If there isn’t an item to displaythe button, you clear the value from the frame table. Next, you need toupdate the script h<strong>and</strong>ler functions. Replace the definitions <strong>of</strong> the OnEnter <strong>and</strong>OnLeave h<strong>and</strong>lers with the following:function BagBuddy_Button_OnEnter(self, motion)if self.link thenGameTooltip:SetOwner(self, “ANCHOR_TOPRIGHT“)GameTooltip:SetHyperlink(self.link)GameTooltip:Show()endendfunction BagBuddy_Button_OnLeave(self, motion)GameTooltip:Hide()endIn the OnEnter h<strong>and</strong>ler, you first check to see if the button is set to displayan item. Then you tell the tooltip to anchor itself to the top right <strong>of</strong> the itembutton, <strong>and</strong> set it to display the item. The corresponding OnLeave script simplyhides the tooltip.If you load the addon <strong>and</strong> run the BagBuddy_Update() function, you shouldbe able to mouse over the items in BagBuddy to display item tooltips.Figure 12-2 shows one such tooltip.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!