Mercurial > wow > reagentmaker
diff SecureMenu.lua @ 2:04c5b817eead
The try to build my own secure menu continues...
author | contrebasse |
---|---|
date | Tue, 29 Mar 2011 22:06:36 +0200 |
parents | 5fc29ed07094 |
children | ed0582126cae |
line wrap: on
line diff
--- a/SecureMenu.lua Mon Mar 28 22:59:20 2011 +0200 +++ b/SecureMenu.lua Tue Mar 29 22:06:36 2011 +0200 @@ -16,18 +16,31 @@ bottom = 11 } }) -MenuFrame:SetWidth(70) +MenuFrame:SetWidth(170) +MenuFrame:SetFrameStrata("DIALOG") + +local MENU_ENTRY_HEIGHT = 12 + local numActiveEntries = 0 local menuEntries = {} +local parentBtn -- The button it's associated with +function A.menuIsOpen(btn) + if btn then + return MenuFrame:IsShown() and (btn==parentBtn) + else + return MenuFrame:IsShown() + end +end function A.menuOpen(parent) A.DEBUG("menuOpen") --if not InCombatLockDown() and numActiveEntries>0 then + parentBtn = parent MenuFrame:ClearAllPoints() - MenuFrame:SetPoint("TOPLEFT",parent,"TOPRIGHT",0,0) + MenuFrame:SetPoint("LEFT",parent,"RIGHT",0,0) - MenuFrame:SetSize(50,50) - MenuFrame:SetParent(UIParent) + MenuFrame:SetHeight(240) + --MenuFrame:SetParent(UIParent) MenuFrame:Show() --end @@ -36,6 +49,7 @@ MenuFrame:Hide() MenuFrame:ClearAllPoints() + parentBtn = nil for i=1,numActiveEntries do menuEntries[i]:Hide() end @@ -46,14 +60,14 @@ local btn -- Create a button only if necessary if numActiveEntries >= #menuEntries then - btn = CreateFrame("Button", nil, MenuFrame, "SecureActionButtonTemplate") + btn = CreateFrame("Button", "ReagentMakerMenuButton"..(#menuEntries+1), MenuFrame) --, "SecureActionButtonTemplate") table.insert(menuEntries,btn) - btn:SetHeight(12) - btn:SetWidth(70) + btn:SetHeight(MENU_ENTRY_HEIGHT) + btn:SetWidth(160) -- Set its position - if #menuEntries==1 then + if #menuEntries==0 then btn:SetPoint("TOPLEFT",MenuFrame,"TOPLEFT",0,0) else btn:SetPoint("TOPLEFT",menuEntries[#menuEntries-1],"BOTTOMLEFT",0,0) @@ -63,7 +77,7 @@ end -- Set its text - btn:SetText(text or " ") + btn:SetText(text or "???") -- Set its action if type(action)=="function" then @@ -80,8 +94,9 @@ -- Reposition MenuFrame --MenuFrame:SetPoint("BOTTOMRIGHT",btn,"BOTTOMRIGHT",0,0) - MenuFrame:SetHeight((numActiveEntries+1)*12) + MenuFrame:SetHeight((numActiveEntries+1)*MENU_ENTRY_HEIGHT) - -- Increase she entry number + -- Increase the entry number numActiveEntries = numActiveEntries + 1 + A.DEBUG("Item added ") end -- function