Thread Tools Display Modes
09-19-19, 07:21 AM   #1
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
HELP: DropdownMenu issue

Alright, so admittedly I've been out of the modding loop for a while now so pardon if the fix for this is obvious and I'm missing it.

I'm having an issue setting up a dropdown menu where after selecting an entry it's marking every other option past it as well:



I looked back on my previous projects and see that I've set them up the same way and they work 100% fine. I've been staring at it for 2 days and can't seem to find anything wrong. Anyone see something I've missed here?

Lua Code:
  1. SLFG_DungeonList = {
  2.     "Ragefire Chasm (RFC)",
  3.     "Wailing Caverns (WC)",
  4.     "Deadmines (VC)",
  5.     "Shadowfang Keep (SFK)",
  6.     "Blackfathom Deeps (BFD)",
  7.     "Stockade (Stocks)",
  8.     "Gnomeregan (Gnomer)",
  9.     "Razorfen Kraul (RFK)",
  10.     "SM: Graveyard (GY)",
  11.     "SM: Library (Lib)",
  12.     "SM: Armory (Armory)",
  13.     "SM: Cathedral (Cath)",
  14.     "Razorfen Downs (RFD)",
  15.     "Uldaman (Ulda)",
  16.     "Zul'Farrack (ZF)",
  17.     "Maraudon (Mara)",
  18.     "Sunken Temple (ST)",
  19.     "Blackrock Depths (BRD)",
  20.     "Lower Blackrock Spire (LBRS)",
  21.     "Upper Blackrock Spire (UBRS)",
  22.     -- "Dire Maul: East (DME)",
  23.     -- "Dire Maul: West (DMW)",
  24.     -- "Dire Maul: North (DMN)",
  25.     "Scholomance (Scholo)",
  26.     "Stratholme: Live (Strat Live)",
  27.     "Stratholme: Dead (Strat Dead)",
  28.     "Molten Core (MC)",
  29.     "Onyxia's Lair (Ony)" }
  30.  
  31. -- DropMenu Creation
  32. dm = CreateFrame("FRAME", "SLFG_DungeonMenu", panel, "UIDropDownMenuTemplate")
  33.             dm:SetPoint("LEFT", "SLFG_DungeonText", "RIGHT", 0, -2)
  34.             UIDropDownMenu_SetWidth(dm, 190)
  35.             UIDropDownMenu_Initialize(dm, SLFG_DungeonMenu_Init)
  36.  
  37. -- DropMenu Setup
  38. function SLFG_DungeonMenu_Init(self)
  39.     local level = level or 1
  40.     local info = UIDropDownMenu_CreateInfo()
  41.    
  42.     for i = 1,#SLFG_DungeonList do
  43.         info.text = SLFG_DungeonList[i]
  44.         info.value = i-1        -- value should start at 0
  45.         info.func = function(self)
  46.             UIDropDownMenu_SetSelectedValue(self.owner, self.value)
  47.             SLFG_Settings.dungeon = SLFG_DungeonList[i]
  48.             print(SLFG_Settings.dungeon.. " has been set.")
  49.             end
  50.         info.owner = self
  51.         info.check = nil
  52.         info.icon = nil
  53.         UIDropDownMenu_AddButton(info, level)
  54.     end
  55. end
  Reply With Quote
09-19-19, 10:08 AM   #2
erispope
A Deviate Faerie Dragon
Join Date: Sep 2019
Posts: 10
Not great at wow UI but you are creating one info and reusing it - could that be a problem?

Secondly, perhaps rewrite the inner function to a reusable one instead of recreating it all the time (use self.value +1 instead of i)?
  Reply With Quote
09-19-19, 11:12 AM   #3
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by erispope View Post
Not great at wow UI but you are creating one info and reusing it - could that be a problem?

Secondly, perhaps rewrite the inner function to a reusable one instead of recreating it all the time (use self.value +1 instead of i)?
info is just a function reference, so it only needs to be made once. The inner function is just a shortcut to iterate through the SLFG_DungeonList creating their respective info. It's basically the equivalent of writing:

Lua Code:
  1. function SLFG_Dungeon_Menu_Init(self)
  2.     local level = level or 1
  3.     local info = UIDropdownMenu_CreateInfo()
  4.    
  5.     info.text = SLFG_DungeonList[1]
  6.     info.value = 0
  7.     info.func = SLFG_DungeonMenuClick
  8.     info.owner = self
  9.     info.check = nil
  10.     info.icon = nil
  11.     UIDropDownMenu_AddButton(info, level) -- creates menu button with current insert
  12.    
  13.     -- this begins reassigning the data next table data
  14.     -- it functions the same as if you did x = 1, immediately followed by x =2
  15.     info.text = SLFG_DungeonList[2]
  16.     info.value = 1
  17.     info.func = SLFG_DungeonMenuClick
  18.     info.owner = self
  19.     info.check = nil
  20.     info.icon = nil
  21.     UIDropDownMenu_AddButton(info, level) -- creates menu button with new info
  22.  
  23.     -- repeat 26 more times for each DungeonList entry
  24. end
  25.    
  26. function SLFG_DungeonMenuClick(self)
  27.     UIDropDownMenu_SetSelectedValue(self.owner, self.value) -- button checkmark itself and updates the dropdown text shown
  28.     if self.value == 0 then
  29.         SLFG_Settings.dungeon = string.match(SLFG_DungeonList[1], "%((%w+)%)")
  30.             print(SLFG_DungeonList[1].. " has been set.")
  31.             SLFG_UpdateMsg()
  32.     elseif self.value == 1 then
  33.             SLFG_Settings.dungeon = string.match(SLFG_DungeonList[2], "%((%w+)%)")
  34.             print(SLFG_DungeonList[2].. " has been set.")
  35.             SLFG_UpdateMsg()
  36.     elseif self.value == 2 then
  37.         -- repeat 26 more times again
  38.     end
  39. end

I have a second dropdown box that is written out the long way, and it does the exact same thing. I compare the functions side by side with the ones I wrote in CFM and from what I've seen they're identical. Yet CFM dropdowns work fine and these don't.

Last edited by Sythalin : 09-19-19 at 11:16 AM.
  Reply With Quote
09-19-19, 06:12 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Code:
List of button attributes
info.owner = [Frame]  --  Dropdown frame that "owns" the current dropdownlist
In the following you would want to pass the button, not the buttons owner (self instead of self.owner).

Code:
function SLFG_DungeonMenuClick(self)
    UIDropDownMenu_SetSelectedValue(self.owner, self.value)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
09-19-19, 08:00 PM   #5
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by Fizzlemizz View Post
Code:
List of button attributes
info.owner = [Frame]  --  Dropdown frame that "owns" the current dropdownlist
In the following you would want to pass the button, not the buttons owner (self instead of self.owner).

Code:
function SLFG_DungeonMenuClick(self)
    UIDropDownMenu_SetSelectedValue(self.owner, self.value)
This is what is already being done in the actual code AFAIK:

Lua Code:
  1. dm = CreateFrame("FRAME", "SLFG_DungeonMenu", panel, "UIDropDownMenuTemplate")
  2.             UIDropDownMenu_Initialize(dm, SLFG_DungeonMenu_Init)  -- passing dm
  3.  
  4. function SLFG_DungeonMenu_Init(self)  -- self = dm
  5.     local info = UIDropDownMenu_CreateInfo()
  6.         info.owner = self -- info.owner = dm
  7.     end
  8. end

When I edit it to
Lua Code:
  1. UIDropDownMenu_SetSelectedValue(self, self.value)
it errors out.

Like I said, the actual functionality works 100% error free, it's just the list automatically checking themselves.

Last edited by Sythalin : 09-19-19 at 08:20 PM.
  Reply With Quote
09-19-19, 08:44 PM   #6
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Lua Code:
  1. local SLFG_DungeonList = {
  2.     "Ragefire Chasm (RFC)",
  3.     "Wailing Caverns (WC)",
  4.     "Deadmines (VC)",
  5.     "Shadowfang Keep (SFK)",
  6.     "Blackfathom Deeps (BFD)",
  7.     "Stockade (Stocks)",
  8.     "Gnomeregan (Gnomer)",
  9.     "Razorfen Kraul (RFK)",
  10.     "SM: Graveyard (GY)",
  11.     "SM: Library (Lib)",
  12.     "SM: Armory (Armory)",
  13.     "SM: Cathedral (Cath)",
  14.     "Razorfen Downs (RFD)",
  15.     "Uldaman (Ulda)",
  16.     "Zul'Farrack (ZF)",
  17.     "Maraudon (Mara)",
  18.     "Sunken Temple (ST)",
  19.     "Blackrock Depths (BRD)",
  20.     "Lower Blackrock Spire (LBRS)",
  21.     "Upper Blackrock Spire (UBRS)",
  22.     -- "Dire Maul: East (DME)",
  23.     -- "Dire Maul: West (DMW)",
  24.     -- "Dire Maul: North (DMN)",
  25.     "Scholomance (Scholo)",
  26.     "Stratholme: Live (Strat Live)",
  27.     "Stratholme: Dead (Strat Dead)",
  28.     "Molten Core (MC)",
  29.     "Onyxia's Lair (Ony)"
  30. }
  31.  
  32. -- DropMenu Setup
  33. local function SLFG_DungeonMenu_Init(self)
  34.     local level = level or 1
  35.     local info = UIDropDownMenu_CreateInfo()
  36.    
  37.    
  38.     for i = 1,#SLFG_DungeonList do
  39.         table.wipe(info)
  40.         info.text = SLFG_DungeonList[i]
  41.         info.value = i-1        -- value should start at 0
  42.         info.func = function(self)
  43.             UIDropDownMenu_SetSelectedValue(self.owner, self.value)
  44. --            SLFG_Settings.dungeon = SLFG_DungeonList[i]
  45. --            print(SLFG_Settings.dungeon.. " has been set.")
  46.             end
  47.         info.owner = self
  48.         info.check = nil
  49.         info.icon = nil
  50.         UIDropDownMenu_AddButton(info, level)
  51.     end
  52. end
  53.  
  54. local dm = CreateFrame("FRAME", "SLFG_DungeonMenu", panel, "UIDropDownMenuTemplate")
  55. dm:SetPoint("LEFT", 20, 0)
  56. UIDropDownMenu_SetWidth(dm, 190)
  57. UIDropDownMenu_Initialize(dm, SLFG_DungeonMenu_Init)

wiped the info table each iteration
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 09-19-19 at 08:49 PM.
  Reply With Quote
09-19-19, 09:36 PM   #7
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by Fizzlemizz View Post
wiped the info table each iteration
No go for me, still doing it. Shift gears a sec, it's also happening on my non-looped dropdown, which has ruled out any potential screwups I may have done with the loop setup:
Lua Code:
  1. dm = CreateFrame("FRAME", "SLFG_RoleMenu", panel, "UIDropDownMenuTemplate")
  2.     dm:SetPoint("LEFT", SLFG_RoleText, "RIGHT", 0, -2)
  3.     UIDropDownMenu_SetWidth(dm, 70)
  4.     UIDropDownMenu_Initialize(dm, SLFG_RoleMenu_Init)
  5.  
  6. function SLFG_RoleMenu_Init(self)
  7.     local info = UIDropDownMenu_CreateInfo()
  8.    
  9.     info.text = "Tank"
  10.     info.value = 0
  11.     info.func = function(self)
  12.         UIDropDownMenu_SetSelectedValue(self.owner, self.value)
  13.         SLFG_Settings.role = "TANK"
  14.         SLFG_UpdateMsg()
  15.         end
  16.     info.owner = self
  17.     info.check = nil
  18.     info.icon = nil
  19.     UIDropDownMenu_AddButton(info)
  20.    
  21.     info.text = "Healer"
  22.     info.value = 1
  23.     info.func = function(self)
  24.         UIDropDownMenu_SetSelectedValue(self.owner, self.value)
  25.         SLFG_Settings.role = "HEALER"
  26.         SLFG_UpdateMsg()
  27.         end
  28.     info.owner = self
  29.     info.check = nil
  30.     info.icon = nil
  31.     UIDropDownMenu_AddButton(info)
  32.    
  33.     info.text = "DPS"
  34.     info.value = 2
  35.     info.func = function(self)
  36.         UIDropDownMenu_SetSelectedValue(self.owner, self.value)
  37.         SLFG_Settings.role = "DPS"
  38.         SLFG_UpdateMsg()
  39.         end
  40.     info.owner = self
  41.     info.check = nil
  42.     info.icon = nil
  43.     UIDropDownMenu_AddButton(info)
  44.    
  45. end
  Reply With Quote
09-19-19, 09:41 PM   #8
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Code:
dm = CreateFrame("FRAME", "SLFG_RoleMenu", panel, "UIDropDownMenuTemplate")
    dm:SetPoint("LEFT", SLFG_RoleText, "RIGHT", 0, -2)
    UIDropDownMenu_SetWidth(dm, 70)
    UIDropDownMenu_Initialize(dm, SLFG_RoleMenu_Init)
If this is the actual order of your code then this is calling SLFG_RoleMenu_Init before the function has been created so I'm guessing there is another version of it somewhere else also global.

Code:
function SLFG_RoleMenu_Init(self)
    local info = UIDropDownMenu_CreateInfo()
    
    info.text = "Tank"
    info.value = 0
    info.func = function(self)
        UIDropDownMenu_SetSelectedValue(self.owner, self.value)
--        SLFG_Settings.role = "TANK"
--        SLFG_UpdateMsg()
        end
    info.owner = self
    info.check = nil
    info.icon = nil
    UIDropDownMenu_AddButton(info)
    
    table.wipe(info)
    info.text = "Healer"
    info.value = 1
    info.func = function(self)
        UIDropDownMenu_SetSelectedValue(self.owner, self.value)
--        SLFG_Settings.role = "HEALER"
--        SLFG_UpdateMsg()
        end
    info.owner = self
    info.check = nil
    info.icon = nil
    UIDropDownMenu_AddButton(info)
    
    table.wipe(info)
    info.text = "DPS"
    info.value = 2
    info.func = function(self)
        UIDropDownMenu_SetSelectedValue(self.owner, self.value)
--        SLFG_Settings.role = "DPS"
--        SLFG_UpdateMsg()
        end
    info.owner = self
    info.check = nil
    info.icon = nil
    UIDropDownMenu_AddButton(info)
    
end

dm = CreateFrame("FRAME", "SLFG_RoleMenu", panel, "UIDropDownMenuTemplate")
dm:SetPoint("LEFT",  20, -2)
UIDropDownMenu_SetWidth(dm, 70)
UIDropDownMenu_Initialize(dm, SLFG_RoleMenu_Init)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 09-19-19 at 09:53 PM.
  Reply With Quote
09-19-19, 10:11 PM   #9
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by Fizzlemizz View Post
Code:
dm = CreateFrame("FRAME", "SLFG_RoleMenu", panel, "UIDropDownMenuTemplate")
    dm:SetPoint("LEFT", SLFG_RoleText, "RIGHT", 0, -2)
    UIDropDownMenu_SetWidth(dm, 70)
    UIDropDownMenu_Initialize(dm, SLFG_RoleMenu_Init)
If this is the actual order of your code then this is calling SLFG_RoleMenu_Init before the function has been created so I'm guessing there is another version of it somewhere else also global.
Confirmed that there is no other SLFG_RoleMenu_init anywhere else, also moved the entire function before the dropdown creation, no change. This is the really odd thing; Here's a snippet from CFM with the exact same setup as my role dropdown and doesn't have this issue. See if you can notice a difference I'm missing (besides the resizing, etc.). The only major difference is that the self.func points to another outside function instead of being constructed locally, which I also set up and tested my current project, no change:

Lua Code:
  1. function SFM_CreatePanel2()
  2.     -- snipped
  3.     dm = CreateFrame("Frame", "SFM_FromBox", f, "UIDropDownMenuTemplate")
  4.         dm:SetPoint("LEFT", SFM_FromText, "RIGHT", -10, -2)
  5.         dm:SetScale(.75)
  6.         UIDropDownMenu_SetWidth(dm,105)
  7.         UIDropDownMenu_Initialize(dm, SFM_FromDropInit)
  8.     -- snipped
  9. end
  10.  
  11. function SFM_FromDropInit(self)
  12.     local info = UIDropDownMenu_CreateInfo()
  13.  
  14.     info.text = "CENTER"
  15.     info.value = 0
  16.     info.func = SFM_FromBoxClick
  17.     info.owner = self
  18.     info.checked = nil
  19.     info.icon = nil
  20.     UIDropDownMenu_AddButton(info)
  21.    
  22.     info.text = "TOP"
  23.     info.value = 1
  24.     info.func = SFM_FromBoxClick
  25.     info.owner = self
  26.     info.checked = nil
  27.     info.icon = nil
  28.     UIDropDownMenu_AddButton(info)
  29.  
  30.     -- snipped
  31. end
  32.  
  33. function SFM_FromBoxClick(self)
  34.     UIDropDownMenu_SetSelectedValue(self.owner, self.value)
  35.     if (self.value == 0) then
  36.         activeProfile[selName].point = "CENTER"
  37.     elseif (self.value == 1) then
  38.         activeProfile[selName].point = "TOP"
  39.     elseif (self.value == 2) then
  40.  
  41.     -- snipped
  42.     end
  43.     SFM_ApplySettings(selName)
  44. end

EDIT:

Last edited by Sythalin : 09-19-19 at 10:20 PM.
  Reply With Quote
09-19-19, 10:19 PM   #10
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Did you move your function or copy mine with the table wipes? The code I posted works here as is.

If you remove/comment out SLFG_RoleMenu_Init you should get a control with no drop list when you press the button.

Code:
function SFM_CreatePanel2()
    -- snipped
    dm = CreateFrame("Frame", "SFM_FromBox", f, "UIDropDownMenuTemplate")
        dm:SetPoint("LEFT", SFM_FromText, "RIGHT", -10, -2)
        dm:SetScale(.75)
        UIDropDownMenu_SetWidth(dm,105)
        UIDropDownMenu_Initialize(dm, SFM_FromDropInit)
    -- snipped
end
the
dm = CreateFrame("Frame", "SFM_FromBox", f, "UIDropDownMenuTemplate")
is inside a function that is proably called after the addon is fully loaded by which time
Code:
function SFM_FromDropInit(self)
will have been created.

To eliminate globals, change the test to:

Code:
local function ABC(self)

    local info = UIDropDownMenu_CreateInfo()
    
    info.text = "Tank"
    info.value = 0
    info.func = function(self)
        UIDropDownMenu_SetSelectedValue(self.owner, self.value)
--        SLFG_Settings.role = "TANK"
--        SLFG_UpdateMsg()
        end
    info.owner = self
    info.check = nil
    info.icon = nil
    UIDropDownMenu_AddButton(info)
    
    table.wipe(info)
    info.text = "Healer"
    info.value = 1
    info.func = function(self)
        UIDropDownMenu_SetSelectedValue(self.owner, self.value)
--        SLFG_Settings.role = "HEALER"
--        SLFG_UpdateMsg()
        end
    info.owner = self
    info.check = nil
    info.icon = nil
    UIDropDownMenu_AddButton(info)
    
    table.wipe(info)
    info.text = "DPS"
    info.value = 2
    info.func = function(self)
        UIDropDownMenu_SetSelectedValue(self.owner, self.value)
--        SLFG_Settings.role = "DPS"
--        SLFG_UpdateMsg()
        end
    info.owner = self
    info.check = nil
    info.icon = nil
    UIDropDownMenu_AddButton(info)
    
end

dm = CreateFrame("FRAME", "SLFG_RoleMenu", panel, "UIDropDownMenuTemplate")
dm:SetPoint("LEFT",  20, -2)
UIDropDownMenu_SetWidth(dm, 70)
UIDropDownMenu_Initialize(dm, ABC)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 09-19-19 at 10:28 PM.
  Reply With Quote
09-19-19, 10:32 PM   #11
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by Fizzlemizz View Post
Did you move your function or copy mine with the table wipes? The code I posted works here as is.

If you remove/comment out SLFG_RoleMenu_Init you should get a control with no drop list when you press the button.
I got it to work now (I forgot to add the table.wipe after each role step) and the dungeon list too. It's odd that it works in without table.wipe and order in CFM, but not in this. But at this point, I'm just glad it finally works so I can publish this thing. Thanks for your help!
  Reply With Quote
09-19-19, 10:40 PM   #12
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by Fizzlemizz View Post
Did you move your function or copy mine with the table wipes? The code I posted works here as is.

snipped
That actually makes sense and something I didn't even consider. In SFM, the GUI is built in a seperate Lua from main file, so yeah, it's probably all loaded up before ADDON_LOADED fires (I'm not 100% savvy on the load vs. toc) whereas currently everything is in a single file in this project. Something I'll have to play with later to make sure I'm up to speed again.

This is what happens when one doesn't build/maintain mods for years in WoW.
  Reply With Quote
09-19-19, 10:42 PM   #13
erispope
A Deviate Faerie Dragon
Join Date: Sep 2019
Posts: 10
I think I found the issue - you are using info.check in the new code, but info.checked in the old code (and checked is what Blizzard code is using).

Once the Blizzard code starts setting info.checked, all further buttons will be considered checked, since you just set "check" to nil, rather than "checked" - this can only happen if Blizzard code is reinitializing the dropdown all the time, which I would hope it wouldn't, but...

I'm sorry for the brevity of my original comment, I'll expound on it a bit. By creating a new function for each button, you are causing unnecessary garbage collection, when your function can easily be rewritten to a reusable format.
Original code:
Lua Code:
  1. function SLFG_DungeonMenu_Init(self)
  2.     local level = level or 1
  3.     local info = UIDropDownMenu_CreateInfo()
  4.    
  5.     for i = 1,#SLFG_DungeonList do
  6.         info.text = SLFG_DungeonList[i]
  7.         info.value = i-1        -- value should start at 0
  8.         info.func = function(self)
  9.             UIDropDownMenu_SetSelectedValue(self.owner, self.value)
  10.             SLFG_Settings.dungeon = SLFG_DungeonList[i]
  11.             print(SLFG_Settings.dungeon.. " has been set.")
  12.             end
  13.         info.owner = self
  14.         info.check = nil
  15.         info.icon = nil
  16.         UIDropDownMenu_AddButton(info, level)
  17.     end
  18. end
Proposed change:
Lua Code:
  1. function SLFG_DungeonMenu_DropdownFunc(self)
  2.     UIDropDownMenu_SetSelectedValue(self.owner, self.value)
  3.     SLFG_Settings.dungeon = SLFG_DungeonList[self.value+1]
  4.     print(SLFG_Settings.dungeon.. " has been set.")
  5. end
  6.  
  7. function SLFG_DungeonMenu_Init(self)
  8.     local level = level or 1
  9.     local info = UIDropDownMenu_CreateInfo()
  10.    
  11.     for i = 1,#SLFG_DungeonList do
  12.         info.text = SLFG_DungeonList[i]
  13.         info.value = i-1        -- value should start at 0
  14.         info.func = SLFG_DungeonMenu_DropdownFunc
  15.         info.owner = self
  16.         info.checked = nil
  17.         info.icon = nil
  18.         UIDropDownMenu_AddButton(info, level)
  19.     end
  20. end

Last edited by erispope : 09-19-19 at 10:50 PM. Reason: Additional exposition and lua highlighting
  Reply With Quote
09-19-19, 11:09 PM   #14
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by erispope View Post
I think I found the issue - you are using info.check in the new code, but info.checked in the old code (and checked is what Blizzard code is using).
Well I'll be damned. This is why I asked if someone would notice something I missed, which I clearly did.

Just for the knowledge to anyone else who may come across this, I reverted the changes made from working with Fizzlemizz to test this (no table.wipe, functions placed back after constructors) and made the change to set.checked. Reloaded and it works as intended.

So both solutions worked, just in different ways (but now adds the mystery on why the Fizzlemizz changes still allowed proper functionality with self.check still in there...)

As for the reformat suggestion, I never gave much thought to it. As I said, I've been out of coding for a few years now, so it didn't strike me that that particular format would cause unnecessary bloat. I have a few other spots I can apply this to as well. Thanks for pointing it out.
  Reply With Quote
09-20-19, 12:49 AM   #15
erispope
A Deviate Faerie Dragon
Join Date: Sep 2019
Posts: 10
No worries, the rust wil come off in no time!

Fizzlemizz solution works by table.wipe, since that should erase checked too.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » HELP: DropdownMenu issue

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off