1 --[[-----------------------------------------------------------------------------
4 -------------------------------------------------------------------------------]]
5 local Type, Version = "Button", 24
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
16 --[[-----------------------------------------------------------------------------
18 -------------------------------------------------------------------------------]]
19 local function Button_OnClick(frame, ...)
21 PlaySound(PlaySoundKitID and "igMainMenuOption" or 852) -- SOUNDKIT.IG_MAINMENU_OPTION
22 frame.obj:Fire("OnClick", ...)
25 local function Control_OnEnter(frame)
26 frame.obj:Fire("OnEnter")
29 local function Control_OnLeave(frame)
30 frame.obj:Fire("OnLeave")
33 --[[-----------------------------------------------------------------------------
35 -------------------------------------------------------------------------------]]
37 ["OnAcquire"] = function(self)
38 -- restore default values
41 self:SetDisabled(false)
42 self:SetAutoWidth(false)
46 -- ["OnRelease"] = nil,
48 ["SetText"] = function(self, text)
49 self.text:SetText(text)
50 if self.autoWidth then
51 self:SetWidth(self.text:GetStringWidth() + 30)
55 ["SetAutoWidth"] = function(self, autoWidth)
56 self.autoWidth = autoWidth
57 if self.autoWidth then
58 self:SetWidth(self.text:GetStringWidth() + 30)
62 ["SetDisabled"] = function(self, disabled)
63 self.disabled = disabled
72 --[[-----------------------------------------------------------------------------
74 -------------------------------------------------------------------------------]]
75 local function Constructor()
76 local name = "AceGUI30Button" .. AceGUI:GetNextWidgetNum(Type)
77 local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate")
80 frame:EnableMouse(true)
81 frame:SetScript("OnClick", Button_OnClick)
82 frame:SetScript("OnEnter", Control_OnEnter)
83 frame:SetScript("OnLeave", Control_OnLeave)
85 local text = frame:GetFontString()
87 text:SetPoint("TOPLEFT", 15, -1)
88 text:SetPoint("BOTTOMRIGHT", -15, 1)
89 text:SetJustifyV("MIDDLE")
96 for method, func in pairs(methods) do
100 return AceGUI:RegisterAsWidget(widget)
103 AceGUI:RegisterWidgetType(Type, Constructor, Version)