This is the first time I've attempted to implement any kind of user interface, so excuse the rest of the code (any tips are very much appreciated, though!), but the main problem I'm having is with my dropdown menus. I've read through Xinhuan's guide and other various code snippets then attempted to reproduce them within the context of my addon, but I'm still having trouble.
The issue itself is related to retrieving my SavedVariables and setting the value of each dropdown to display them when the addon's first loaded. When I login or reload my UI and type /fat config to bring up the interface, this is what I'm presented with:
As you can see, each dropdown list displays "Custom", which I assume is the default value if there's something's not right/the value you've tried to set is nil. The strange thing is, in the following screenshot, after clicking the dropdown arrow, you can see it's actually selecting the correct value from the list. Attempts to manually call UIDropDownMenu_SetText() to override the "Custom" text didn't help:
Now, without manually clicking anything in the list, if I close the configuration dialog, and type /fat config to open it again, it displays the correct values:
The dropdown menus are created between lines 238-243 in Fatality_Options.lua, which is within a function called after ADDON_LOADED has fired.
Code(Ignore any messy comments and so on, it's still a work in progress!) Fatality.lua[probably not relevant to the actual problem, but I'll include it anyway] Fatality_Options.lua
I've literally been trying to figure this out for around 4 hours now and have come here as a last resort, so if I've made a simple mistake and not realised it, I'll be mildly agitated to say the least! :p
Problem solved, HUGE thanks to jnwhiteh and foxlit for their help!
For any one else experiencing similar issues, the solution required me to add [FONT="Courier New"]UIDropDownMenu_Initialize()[/FONT] calls before each [FONT="Courier New"]UIDropDownMenu_SetSelectedValue()[/FONT] and [FONT="Courier New"]UIDropDownMenu_SetSelectedID()[/FONT] call.
Why aren't you just adding your options to the Interface Options window where users these days expect addon options to be? It would even save you some code, since you would not need to give your container frame a backdrop or border, and you would not need to handle showing and hiding the frame yourself.
As I mentioned in my original post, this is the first user interface I've attempted to implement, so it's a learning experience for me, which is why I'm first experimenting with the various methods available, i.e. to understand them, then decide which to use.
I may well go with your suggestion in the end, but initially I liked the idea of being able to fully customise the appearance of my addon's option menu, which I also figured would be harder to do and I'd therefore learn more along the way.