|
09-19-19, 07:21 AM | #1 |
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:
|
|
09-19-19, 10:08 AM | #2 |
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)? |
|
09-19-19, 11:12 AM | #3 | |
Lua Code:
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. |
||
09-19-19, 06:12 PM | #4 |
Code:
List of button attributes info.owner = [Frame] -- Dropdown frame that "owns" the current dropdownlist 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. |
|
09-19-19, 08:00 PM | #5 | |
Lua Code:
When I edit it to Lua Code:
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. |
||
09-19-19, 08:44 PM | #6 |
Lua Code:
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. |
|
09-19-19, 09:36 PM | #7 |
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:
|
|
09-19-19, 09:41 PM | #8 |
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) 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. |
|
09-19-19, 10:11 PM | #9 | |
Lua Code:
EDIT: Last edited by Sythalin : 09-19-19 at 10:20 PM. |
||
09-19-19, 10:19 PM | #10 |
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 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) 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. |
|
09-19-19, 10:32 PM | #11 |
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!
|
|
09-19-19, 10:40 PM | #12 | |
This is what happens when one doesn't build/maintain mods for years in WoW. |
||
09-19-19, 10:42 PM | #13 |
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:
Lua Code:
Last edited by erispope : 09-19-19 at 10:50 PM. Reason: Additional exposition and lua highlighting |
|
09-19-19, 11:09 PM | #14 | |
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. |
||
09-20-19, 12:49 AM | #15 |
No worries, the rust wil come off in no time!
Fizzlemizz solution works by table.wipe, since that should erase checked too. |
|
WoWInterface » Developer Discussions » Lua/XML Help » HELP: DropdownMenu issue |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Switch to Linear Mode |
Hybrid Mode |
Switch to Threaded Mode |
|
|