1 --[[-----------------------------------------------------------------------------
4 -------------------------------------------------------------------------------]]
5 local Type, Version = "Button", 23
6 local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
7 if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
14 local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent
18 local _, _, _, interface = GetBuildInfo()
19 wowMoP = (interface >= 50000)
22 --[[-----------------------------------------------------------------------------
24 -------------------------------------------------------------------------------]]
25 local function Button_OnClick(frame, ...)
27 PlaySound("igMainMenuOption")
28 frame.obj:Fire("OnClick", ...)
31 local function Control_OnEnter(frame)
32 frame.obj:Fire("OnEnter")
35 local function Control_OnLeave(frame)
36 frame.obj:Fire("OnLeave")
39 --[[-----------------------------------------------------------------------------
41 -------------------------------------------------------------------------------]]
43 ["OnAcquire"] = function(self)
44 -- restore default values
47 self:SetDisabled(false)
48 self:SetAutoWidth(false)
52 -- ["OnRelease"] = nil,
54 ["SetText"] = function(self, text)
55 self.text:SetText(text)
56 if self.autoWidth then
57 self:SetWidth(self.text:GetStringWidth() + 30)
61 ["SetAutoWidth"] = function(self, autoWidth)
62 self.autoWidth = autoWidth
63 if self.autoWidth then
64 self:SetWidth(self.text:GetStringWidth() + 30)
68 ["SetDisabled"] = function(self, disabled)
69 self.disabled = disabled
78 --[[-----------------------------------------------------------------------------
80 -------------------------------------------------------------------------------]]
81 local function Constructor()
82 local name = "AceGUI30Button" .. AceGUI:GetNextWidgetNum(Type)
83 local frame = CreateFrame("Button", name, UIParent, wowMoP and "UIPanelButtonTemplate" or "UIPanelButtonTemplate2")
86 frame:EnableMouse(true)
87 frame:SetScript("OnClick", Button_OnClick)
88 frame:SetScript("OnEnter", Control_OnEnter)
89 frame:SetScript("OnLeave", Control_OnLeave)
91 local text = frame:GetFontString()
93 text:SetPoint("TOPLEFT", 15, -1)
94 text:SetPoint("BOTTOMRIGHT", -15, 1)
95 text:SetJustifyV("MIDDLE")
102 for method, func in pairs(methods) do
103 widget[method] = func
106 return AceGUI:RegisterAsWidget(widget)
109 AceGUI:RegisterWidgetType(Type, Constructor, Version)