-
Posted by Taborious on Mon, 10 Jun 2013 19:08:11
I have 30 dropdown menus used on one screen of my addon. The selection within all of those dropdowns is based of the selection of a main dropdown menu on the page. So when the main dropdown changes the 30 others need to update their menu selections. Im having an issue trying to figure out how to do that.
My menus show and I can have them populate with one set of selections just fine. But I cant figure out how to update those menus on a change. so remove the current selections and add a new set. Below is the code im using for my DDMs
if not BG_Planner_DDM then CreateFrame("Button", "BG_Planner_BG_Select_DDM", BG_Planner_Frame_Legend, "UIDropDownMenuTemplate") end BG_Planner_BG_Select_DDM:ClearAllPoints() BG_Planner_BG_Select_DDM:SetPoint("LEFT", 150, 12) BG_Planner_BG_Select_DDM:Show() local items = {"Select BG", "Arathi Basin", "Warsong Gulch", "Eye of the Storm", "Strands of the Ancient", "Battle for Gilneas", "Twin Peaks", "Silvershard Mines", "Temple of Kotmogu", "Deepwind Gorge"} local function OnClick(self) UIDropDownMenu_SetSelectedID(BG_Planner_BG_Select_DDM, self:GetID()) BG_Planner_ProcessDDM(self.value) end local function initialize(self, level) local info = UIDropDownMenu_CreateInfo() for k,v in pairs(items) do info = UIDropDownMenu_CreateInfo() info.text = v info.value = v info.func = OnClick UIDropDownMenu_AddButton(info, level) end end UIDropDownMenu_Initialize(BG_Planner_BG_Select_DDM, initialize) UIDropDownMenu_SetWidth(BG_Planner_BG_Select_DDM, 140); UIDropDownMenu_SetButtonWidth(BG_Planner_BG_Select_DDM, 124) UIDropDownMenu_SetSelectedID(BG_Planner_BG_Select_DDM, 1) UIDropDownMenu_JustifyText(BG_Planner_BG_Select_DDM, "LEFT")
-
Posted by tom022 on Wed, 12 Jun 2013 02:15:13
I don't have time right now. I create this code very quickly check it and tell me is it work. I can write more but not tooday. Code below is same here http://ideone.com/n09ChE for better look
PS: Sorry for Language
DropDownMenu1 = CreateFrame("Button", "DropDownMenuTest", UIParent, "UIDropDownMenuTemplate") --write here your code to add some "items" to drop down menu and rest of code --that is needed to create it correct DropDownMenu1:RegisterEvent("OnClick")--add on click event to register event DropDownMenu1:SetScript("OnClick",UploadDropDownMenu2) -- handle function --UnploadDropDownMenu1 when DropDownMenu1 is pressed DropDownMenu2 = CreateFrame("Button", "DropDownMenuTest2", UIParent, "UIDropDownMenuTemplate") --write here your code to add some "items" to drop down menu and rest of code --that is needed to create it correct DropDownMenu2:RegisterEvent("OnClick") DropDownMenu2:SetScript("OnClick",UploadDropDownMenu3)--handle function --UnploadDropDownMenu2 when DropDownMenu1 is pressed DropDownMenu3 = CreateFrame("Button", "DropDownMenuTest3", UIParent, "UIDropDownMenuTemplate") --write here your code to add some "items" to drop down menu and rest of code --that is needed to create it correct local items = { "Alpha", "Beta", "Gamma", "Delta", } function UploadDropDownMenu2() -- this function is called when DropDownMenu1 i Clicked local function initialize(self, level) local info = this for k,v in pairs(items) do info = UIDropDownMenu_CreateInfo() info.text = v info.value = v info.func = OnClick UIDropDownMenu_AddButton(info, level) end end end function UploadDropDownMenu3()-- this function is called when DropDownMenu12 i Clicked local function initialize(self, level) local info = this for k,v in pairs(items) do info = UIDropDownMenu_CreateInfo() info.text = v info.value = v info.func = OnClick UIDropDownMenu_AddButton(info, level) end end end
-
Posted by Taborious on Thu, 13 Jun 2013 18:31:43
Thanks for the post. I looked at that and did the best I could but still having no luck. Ill explain my setup and post my update section below.
I have 2 columns of 15 dropdowns each named individually when initially created. Column1-1 Column1-2 ... Column1-15 Column2-1 Column2-2 ... Column2-15
I then have one main dropdown menu. That main dropdown has a listing of Battlegrounds, AB, Eye, WSG... When the BG is selected I want to update the 30 dropdowns with info specific for that BG. My column dropdown draw fine and my main populates and works fine. When I click the BG select DDM it runs the update function I want it to because I have debug going to chat and can see it. BUT it doesnt update any data in the 30 dropdowns
`function BGPlannerProcessDDM(selectedBG)
items = {"No Assignment", "ST", "BS", "LM", "GM", "Farm", "Offense1", "Offense2", "Backup ST", "Backup BS","Backup LM","Backup GM","Backup Farm", "Flag Spinner1", "Flag Spinner2", "CC1", "CC2", "CC3"} if (BG_Planner_Debug == "yes") then DEFAULT_CHAT_FRAME:AddMessage("BG Planner Debug: DDM update: "..items[3]) end for columnCount = 1, 2 do -- This for section create one column of dropdown menus for the raid for raidCount = 1, NumRaidMembers do local BG_Planner_DDM = "Column"..columnCount.."-"..raidCount if columnCount == 2 then colTemp = colSecondary else colTemp = colPrimary end if (BG_Planner_Debug == "yes") then DEFAULT_CHAT_FRAME:AddMessage("BG Planner Debug: DDM update: "..BG_Planner_DDM) end local function initialize(BG_Planner_DDM, level) if (BG_Planner_Debug == "yes") then DEFAULT_CHAT_FRAME:AddMessage("BG Planner Debug: "..v) end local info = UIDropDownMenu_CreateInfo() for k,v in pairs(items) do info = UIDropDownMenu_CreateInfo() info.text = v info.value = v UIDropDownMenu_AddButton(info, level) end end end end if (BG_Planner_Debug == "yes") then DEFAULT_CHAT_FRAME:AddMessage("BG Planner Debug: "..selectedBG) end if (BG_Planner_Debug == "yes") then DEFAULT_CHAT_FRAME:AddMessage("BG Planner Debug: END update dropdowns with new BG selection") end
end`
-
Posted by tom022 on Fri, 14 Jun 2013 07:10:28
i write an addon for you. Run this in game after, read the code. this code isn't very good. I just write this for you :D
https://www.dropbox.com/s/jsd2tvhkmle8ac2/idChecker.rar
if you are scary of Virus here is code
File Core.lua https://docs.google.com/file/d/0Bzn1hIzpHkn9dS1ranpBa3lZVmM/edit
File IDCCoreFrame.xml(you dont have to look at this its only frame) https://docs.google.com/file/d/0Bzn1hIzpHkn9aTN6b3plSjV1eEU/edit?usp=sharing
and File idChecker.toc https://docs.google.com/file/d/0Bzn1hIzpHkn9X3BKMFc5VGZtbWM/edit?usp=sharing
PS: Don't look at addon name, i just change an other addon code
-
Posted by Taborious on Sat, 15 Jun 2013 15:00:42
Thanks for the post! with that I was able to get my menus to populate. I now have a new question. For the initialize function how can you pass the frame name as a variable?
UIDropDownMenuInitialize(Frame, DDMInitialize)
If I try to use a variable in place of "Frame" it kicks an error.