Mercurial > wow > askmrrobot
diff ui/ItemTooltipFrame.lua @ 0:ec731d2fe6ba
Version 1.2.12.0
author | Adam tegen <adam.tegen@gmail.com> |
---|---|
date | Tue, 20 May 2014 21:43:23 -0500 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/ItemTooltipFrame.lua Tue May 20 21:43:23 2014 -0500 @@ -0,0 +1,46 @@ +local _, AskMrRobot = ... + +-- initialize the ItemLink class +AskMrRobot.ItemTooltipFrame = AskMrRobot.inheritsFrom(AskMrRobot.Frame) + +-- item link contructor +function AskMrRobot.ItemTooltipFrame:new(name, parent) + -- create a new frame + local o = AskMrRobot.Frame:new(name, parent) + + -- use the ItemTooltipFrame class + setmetatable(o, { __index = AskMrRobot.ItemTooltipFrame }) + + o.tooltipShown = false + + -- initialize the enter/leave scripts for showing the tooltips + o:SetScript("OnEnter", AskMrRobot.ItemTooltipFrame.OnEnterTooltipFrame) + o:SetScript("OnLeave", AskMrRobot.ItemTooltipFrame.OnLeaveTooltipFrame) + + -- return the instance of the ItemTooltipFrame + return o +end + +function AskMrRobot.ItemTooltipFrame:OnEnterTooltipFrame() + if self.itemLink then + GameTooltip:SetOwner(self, "ANCHOR_CURSOR") + + GameTooltip:SetHyperlink(self.itemLink) + + GameTooltip:Show() + self.tooltipShown = true + end +end + +function AskMrRobot.ItemTooltipFrame:OnLeaveTooltipFrame() + GameTooltip:Hide() + self.tooltipShown = false +end + +-- set the tooltip from the specified item link +function AskMrRobot.ItemTooltipFrame:SetItemLink(link) + if self.tooltipShown then + GameTooltip:Hide() + end + self.itemLink = link +end