Mercurial > wow > reagentmaker
view SecureMenu.lua @ 1:5fc29ed07094
First atempt at using secure menus, it doesn't open yet...
author | contrebasse |
---|---|
date | Mon, 28 Mar 2011 22:59:20 +0200 |
parents | eba26c900e99 |
children | 04c5b817eead |
line wrap: on
line source
local addonName, A = ... -- Create the menu frame local MenuFrame = CreateFrame("Frame",nil,UIParent) --, "ReagentMakerDropDownMenu"); -- Needs a global name MenuFrame:Hide() MenuFrame:SetBackdrop({ bgFile = "Interface\\DialogFrame\\UI-DialogBox-Gold-Background", -- path to the background texture edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Gold-Border", -- path to the border texture tile = true, -- true to repeat the background texture to fill the frame, false to scale it tileSize = 32, -- size (width or height) of the square repeating background tiles (in pixels) edgeSize = 32, -- thickness of edge segments and square size of edge corners (in pixels) insets = { -- distance from the edges of the frame to those of the background texture (in pixels) left = 11, right = 12, top = 12, bottom = 11 } }) MenuFrame:SetWidth(70) local numActiveEntries = 0 local menuEntries = {} function A.menuOpen(parent) A.DEBUG("menuOpen") --if not InCombatLockDown() and numActiveEntries>0 then MenuFrame:ClearAllPoints() MenuFrame:SetPoint("TOPLEFT",parent,"TOPRIGHT",0,0) MenuFrame:SetSize(50,50) MenuFrame:SetParent(UIParent) MenuFrame:Show() --end end function A.menuClose() MenuFrame:Hide() MenuFrame:ClearAllPoints() for i=1,numActiveEntries do menuEntries[i]:Hide() end end function A.menuAddItem(text,action,itemID) A.DEBUG("menuAddItem "..text) local btn -- Create a button only if necessary if numActiveEntries >= #menuEntries then btn = CreateFrame("Button", nil, MenuFrame, "SecureActionButtonTemplate") table.insert(menuEntries,btn) btn:SetHeight(12) btn:SetWidth(70) -- Set its position if #menuEntries==1 then btn:SetPoint("TOPLEFT",MenuFrame,"TOPLEFT",0,0) else btn:SetPoint("TOPLEFT",menuEntries[#menuEntries-1],"BOTTOMLEFT",0,0) end else btn = menuEntries[numActiveEntries+1] end -- Set its text btn:SetText(text or " ") -- Set its action if type(action)=="function" then btn:SetScript("OnClick",action) btn:SetAttribute("type", nil) btn:SetAttribute("spell", nil) btn:SetAttribute("target-item",itemID) elseif type(action)=="string" then btn:SetScript("OnClick",nil) btn:SetAttribute("type", "spell") btn:SetAttribute("spell", action) btn:SetAttribute("target-item",GetItemInfo(itemID)) end -- if -- Reposition MenuFrame --MenuFrame:SetPoint("BOTTOMRIGHT",btn,"BOTTOMRIGHT",0,0) MenuFrame:SetHeight((numActiveEntries+1)*12) -- Increase she entry number numActiveEntries = numActiveEntries + 1 end -- function