comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:ec731d2fe6ba
1 local _, AskMrRobot = ...
2
3 -- initialize the ItemLink class
4 AskMrRobot.ItemTooltipFrame = AskMrRobot.inheritsFrom(AskMrRobot.Frame)
5
6 -- item link contructor
7 function AskMrRobot.ItemTooltipFrame:new(name, parent)
8 -- create a new frame
9 local o = AskMrRobot.Frame:new(name, parent)
10
11 -- use the ItemTooltipFrame class
12 setmetatable(o, { __index = AskMrRobot.ItemTooltipFrame })
13
14 o.tooltipShown = false
15
16 -- initialize the enter/leave scripts for showing the tooltips
17 o:SetScript("OnEnter", AskMrRobot.ItemTooltipFrame.OnEnterTooltipFrame)
18 o:SetScript("OnLeave", AskMrRobot.ItemTooltipFrame.OnLeaveTooltipFrame)
19
20 -- return the instance of the ItemTooltipFrame
21 return o
22 end
23
24 function AskMrRobot.ItemTooltipFrame:OnEnterTooltipFrame()
25 if self.itemLink then
26 GameTooltip:SetOwner(self, "ANCHOR_CURSOR")
27
28 GameTooltip:SetHyperlink(self.itemLink)
29
30 GameTooltip:Show()
31 self.tooltipShown = true
32 end
33 end
34
35 function AskMrRobot.ItemTooltipFrame:OnLeaveTooltipFrame()
36 GameTooltip:Hide()
37 self.tooltipShown = false
38 end
39
40 -- set the tooltip from the specified item link
41 function AskMrRobot.ItemTooltipFrame:SetItemLink(link)
42 if self.tooltipShown then
43 GameTooltip:Hide()
44 end
45 self.itemLink = link
46 end