1 --[[-----------------------------------------------------------------------------
2 InteractiveLabel Widget
3 -------------------------------------------------------------------------------]]
4 local Type, Version = "InteractiveLabel", 21
5 local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
6 if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
9 local select, pairs = select, pairs
12 local CreateFrame, UIParent = CreateFrame, UIParent
14 -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
15 -- List them here for Mikk's FindGlobals script
16 -- GLOBALS: GameFontHighlightSmall
18 --[[-----------------------------------------------------------------------------
20 -------------------------------------------------------------------------------]]
21 local function Control_OnEnter(frame)
22 frame.obj:Fire("OnEnter")
25 local function Control_OnLeave(frame)
26 frame.obj:Fire("OnLeave")
29 local function Label_OnClick(frame, button)
30 frame.obj:Fire("OnClick", button)
34 --[[-----------------------------------------------------------------------------
36 -------------------------------------------------------------------------------]]
38 ["OnAcquire"] = function(self)
41 self:SetHighlightTexCoord()
42 self:SetDisabled(false)
45 -- ["OnRelease"] = nil,
47 ["SetHighlight"] = function(self, ...)
48 self.highlight:SetTexture(...)
51 ["SetHighlightTexCoord"] = function(self, ...)
52 local c = select("#", ...)
53 if c == 4 or c == 8 then
54 self.highlight:SetTexCoord(...)
56 self.highlight:SetTexCoord(0, 1, 0, 1)
60 ["SetDisabled"] = function(self,disabled)
61 self.disabled = disabled
63 self.frame:EnableMouse(false)
64 self.label:SetTextColor(0.5, 0.5, 0.5)
66 self.frame:EnableMouse(true)
67 self.label:SetTextColor(1, 1, 1)
72 --[[-----------------------------------------------------------------------------
74 -------------------------------------------------------------------------------]]
75 local function Constructor()
76 -- create a Label type that we will hijack
77 local label = AceGUI:Create("Label")
79 local frame = label.frame
80 frame:EnableMouse(true)
81 frame:SetScript("OnEnter", Control_OnEnter)
82 frame:SetScript("OnLeave", Control_OnLeave)
83 frame:SetScript("OnMouseDown", Label_OnClick)
85 local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
86 highlight:SetTexture(nil)
87 highlight:SetAllPoints()
88 highlight:SetBlendMode("ADD")
90 label.highlight = highlight
92 label.LabelOnAcquire = label.OnAcquire
93 for method, func in pairs(methods) do
100 AceGUI:RegisterWidgetType(Type, Constructor, Version)