Mercurial > wow > reagentmaker
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 0:eba26c900e99 | 1:5fc29ed07094 |
|---|---|
| 14 right = 12, | 14 right = 12, |
| 15 top = 12, | 15 top = 12, |
| 16 bottom = 11 | 16 bottom = 11 |
| 17 } | 17 } |
| 18 }) | 18 }) |
| 19 MenuFrame:SetWidth(70) | |
| 19 local numActiveEntries = 0 | 20 local numActiveEntries = 0 |
| 20 local menuEntries = {} | 21 local menuEntries = {} |
| 21 | 22 |
| 22 function A.menuOpen() | 23 function A.menuOpen(parent) |
| 23 if not InCombatLockDown() and numActiveEntries>0 then | 24 A.DEBUG("menuOpen") |
| 25 --if not InCombatLockDown() and numActiveEntries>0 then | |
| 26 MenuFrame:ClearAllPoints() | |
| 27 MenuFrame:SetPoint("TOPLEFT",parent,"TOPRIGHT",0,0) | |
| 28 | |
| 29 MenuFrame:SetSize(50,50) | |
| 30 MenuFrame:SetParent(UIParent) | |
| 31 | |
| 24 MenuFrame:Show() | 32 MenuFrame:Show() |
| 25 end | 33 --end |
| 26 end | 34 end |
| 27 function A.menuClose() | 35 function A.menuClose() |
| 28 MenuFrame:Hide() | 36 MenuFrame:Hide() |
| 29 MenuFrame:ClearAllPoints() | 37 MenuFrame:ClearAllPoints() |
| 30 | 38 |
| 32 menuEntries[i]:Hide() | 40 menuEntries[i]:Hide() |
| 33 end | 41 end |
| 34 end | 42 end |
| 35 | 43 |
| 36 function A.menuAddItem(text,action,itemID) | 44 function A.menuAddItem(text,action,itemID) |
| 45 A.DEBUG("menuAddItem "..text) | |
| 37 local btn | 46 local btn |
| 38 -- Create a button only if necessary | 47 -- Create a button only if necessary |
| 39 if numActiveEntries >= #menuEntries then | 48 if numActiveEntries >= #menuEntries then |
| 40 btn = CreateFrame("Button", nil, MenuFrame, "SecureActionButtonTemplate") | 49 btn = CreateFrame("Button", nil, MenuFrame, "SecureActionButtonTemplate") |
| 41 table.insert(menuEntries,btn) | 50 table.insert(menuEntries,btn) |
| 42 | 51 |
| 43 btn:SetHeight(12) | 52 btn:SetHeight(12) |
| 53 btn:SetWidth(70) | |
| 44 | 54 |
| 45 -- Set its position | 55 -- Set its position |
| 46 if #menuEntries==1 then | 56 if #menuEntries==1 then |
| 47 btn:SetPoint("TOPLEFT",MenuFrame,"TOPLEFT",0,0) | 57 btn:SetPoint("TOPLEFT",MenuFrame,"TOPLEFT",0,0) |
| 48 else | 58 else |
| 58 -- Set its action | 68 -- Set its action |
| 59 if type(action)=="function" then | 69 if type(action)=="function" then |
| 60 btn:SetScript("OnClick",action) | 70 btn:SetScript("OnClick",action) |
| 61 btn:SetAttribute("type", nil) | 71 btn:SetAttribute("type", nil) |
| 62 btn:SetAttribute("spell", nil) | 72 btn:SetAttribute("spell", nil) |
| 63 btn:SetAttribute("target-item",nil) | 73 btn:SetAttribute("target-item",itemID) |
| 64 elseif type(action)=="string" then | 74 elseif type(action)=="string" then |
| 65 btn:SetScript("OnClick",nil) | 75 btn:SetScript("OnClick",nil) |
| 66 btn:SetAttribute("type", "spell") | 76 btn:SetAttribute("type", "spell") |
| 67 btn:SetAttribute("spell", action) | 77 btn:SetAttribute("spell", action) |
| 68 btn:SetAttribute("target-item",GetItemInfo(itemID)) | 78 btn:SetAttribute("target-item",GetItemInfo(itemID)) |
| 69 end -- if | 79 end -- if |
| 70 | 80 |
| 71 -- Reposition MenuFrame | 81 -- Reposition MenuFrame |
| 72 MenuFrame:SetPoint("BOTTOMRIGHT",btn,"BOTTOMRIGHT",0,0) | 82 --MenuFrame:SetPoint("BOTTOMRIGHT",btn,"BOTTOMRIGHT",0,0) |
| 83 MenuFrame:SetHeight((numActiveEntries+1)*12) | |
| 73 | 84 |
| 74 -- Increase she entry number | 85 -- Increase she entry number |
| 75 numActiveEntries = numActiveEntries + 1 | 86 numActiveEntries = numActiveEntries + 1 |
| 76 end -- function | 87 end -- function |
