View Single Post
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