The data in
info is volatile so you can't really use it as you tried since each new button you need to create will be writing over the previous buttons data. However, most of the fields are copied into the button you are setting up and that button is the first argument passed to the function you supply (info.func).
Your menu doesn't really need a close button since anything you click in the menu will close it anyway, and you can also click the button that opened it to just toggle it closed. Also, there is no real need to keep your own local info table since Blizzard provides the function UIDropDownMenu_CreateInfo for just this purpose.
I would change that linked code to something more along the lines of:
Code:
local Pipican_strategySelectionMenu = CreateFrame("Frame", "Pipican_strategySelectionMenu")
Pipican_strategySelectionMenu.displayMode = "MENU"
local function menuOnClick(self)
PipicanOptions["commandCenterFrame_" .. GetTechBGNameByLarge(GetRealZoneText()) .. "_spammedStrategy"] = self.value
end
Pipican_strategySelectionMenu.initialize = function(self, level)
local info = UIDropDownMenu_CreateInfo()
info.isTitle = true
info.text = "Select strategy to spam"
info.notCheckable = true
UIDropDownMenu_AddButton(info, level)
info.disabled = nil
info.isTitle = nil
info.notCheckable = nil
info.func = menuOnClick
local techGBName = GetTechBGNameByLarge(GetRealZoneText())
local dataStrategies, options = Pipican_dataStrategies[techBGName], PipicanOptions["commandCenterFrame_" .. techBGName .. "_spammedStrategy"]
for i = 1, #dataStrategies do
info.checked = options == i
info.text = dataStrategies[i].name
info.value = i
UIDropDownMenu_AddButton(info, level)
end
end
Pipican_switchMode_RaidModeButton:SetScript("OnClick", function(self, button, down)
if button == "RightButton" then
ToggleDropDownMenu(1, nil, Pipican_strategySelectionMenu, self:GetName(), 0, 0)
end
end)
Pipican_switchMode_RaidModeButton:RegisterForClicks("RightButtonUp")