From 8c75f872c6d8a60f10a17ff2175da9dddc6201c4 Mon Sep 17 00:00:00 2001 From: Darthpred Date: Mon, 20 Apr 2015 01:38:05 +0400 Subject: [PATCH] A wall of text on how to insert own buttons to UB module --- ElvUI_SLE/modules/uibuttons.lua | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/ElvUI_SLE/modules/uibuttons.lua b/ElvUI_SLE/modules/uibuttons.lua index cf91cef..db55edf 100644 --- a/ElvUI_SLE/modules/uibuttons.lua +++ b/ElvUI_SLE/modules/uibuttons.lua @@ -116,6 +116,32 @@ function UB:CreateCoreButton(name, text) end end + +--[[ +A function to create a dropdown button for pretty much anything in any UB's dropdown. +UB:CreateDropdownButton(parent, name, text, tooltip1, tooltip2, click, addon) + +parent - a group the button will be in: Config, Addon, Status, Roll +name - unique button's name used for table reference and actual name creation +text - a string that will be shown on button +tooltip1 - upper line of button's tooltip shown in greay color. Mandatory for creating a tooltip. If tooltip is not needed set to nil +tooltip2 - lower line of the tooltip shown in white color. If not needed set to nil +click - a function executed on button click. Preferably in the form of function() end +addon - if button's function requires an addon to function should be addon's name for IsAddOnLoaded check. the button will not be shown if check is failed. + +To hook your button into UB dropdown use this method: + +local function MyButtonInsert() + UB:CreateDropdownButton(parent, name, text, tooltip1, tooltip2, click, addon) + tinsert(UB.AddonTable, UB.menuHolder[parent][name]) + UB:FrameSize(true) +end +hooksecurefunc(UB, "Initialize", MyButtonInsert) + +You can have as many buttons created inside your function as you want. + +]] + function UB:CreateDropdownButton(parent, name, text, tooltip1, tooltip2, click, addon) UB.menuHolder[parent][name] = CreateFrame("Button", "SLEUI"..parent..name, UB.menuHolder[parent]) local b = UB.menuHolder[parent][name] @@ -155,7 +181,7 @@ function UB:CreateDropdownButton(parent, name, text, tooltip1, tooltip2, click, UB:OnEnter() GameTooltip:SetOwner(self) GameTooltip:AddLine(tooltip1, .6, .6, .6, .6, .6, 1) - GameTooltip:AddLine(tooltip2, 1, 1, 1, 1, 1, 1) + if tooltip2 then GameTooltip:AddLine(tooltip2, 1, 1, 1, 1, 1, 1) end GameTooltip:Show() end) b:SetScript("OnLeave", function(self) -- 1.7.9.5