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:
|
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)? |
Quote:
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. |
Code:
List of button attributes Code:
function SLFG_DungeonMenuClick(self) |
Quote:
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. |
Lua Code:
wiped the info table each iteration |
Quote:
Lua Code:
|
Code:
dm = CreateFrame("FRAME", "SLFG_RoleMenu", panel, "UIDropDownMenuTemplate") Code:
function SLFG_RoleMenu_Init(self) |
Quote:
Lua Code:
EDIT: |
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() 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) |
Quote:
|
Quote:
This is what happens when one doesn't build/maintain mods for years in WoW. :D |
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:
|
Quote:
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. |
No worries, the rust wil come off in no time!
Fizzlemizz solution works by table.wipe, since that should erase checked too. |
All times are GMT -6. The time now is 01:15 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI