-
Posted by emmote on Thu, 01 Nov 2012 17:05:10
Heya,
I've been looking around for almost a week now and I've really not been able to find any definitive answer to my problem.
I have a load of DropDownMenu's (UIDropDownMenuTemplate) and I need to be able to find out their currently selected value and even change it - remotely. I don't need to add or remove buttons, just change which one is selected or find out which one is selected - or both.
For example, I have a DropDownMenu who's buttons are reputation values {"Neutral", "Friendly", etc.}; But I need to be able to change which one is selected, probably a long time after it's been created. Essentially I need a Set and Get for it.
I know I have to do something when it's initialised to be able to manipulate it but for the life of me I can't find anything that works.
Edit: I forgot to mention I'd rather not have to use XML.
I appreciate any help anyone could give me, thank you. --Emmo
-
Posted by jnwhiteh on Fri, 02 Nov 2012 06:34:20
http://wowprogramming.com/snippets/CreateUI-styleddropdownmenu10 should contain everything you need.
-
Posted by emmote on Fri, 02 Nov 2012 08:31:39
Ok, I think I get it. I tried initializing the DropDownMenu's whenever I need to get or set their value, and then immediately using Set or GetSelectedID.
Problem is, if I use it like this, the text in the DropDownMenu always comes up as "Custom", even though the ID is correct and when I click on the DropDownMenu it shows the correct item being selected.
Is there any way to fix that?
-
Posted by jnwhiteh on Fri, 02 Nov 2012 19:59:33
I think you can call SetText or whatever it is to set it? They've changed this particular thing so many times its pretty frustrating remembering which version of wacky we're on =)
-
Posted by emmote on Fri, 02 Nov 2012 20:06:37
Ok, I'll give it a go. Cheers for the help. :)
-
Posted by emmote on Sat, 03 Nov 2012 14:37:57
Well, I've found something that works, but it's a bit ugly.
ToggleDropDownMenu(1, nil, DDM); UIDropDownMenu_SetSelectedID(DDM, id); ToggleDropDownMenu(1, nil, DDM);
Basically it opens the DropDownMenu, changes the ID, then closes it again. Like I said, ugly, but it works.
Nothing else I've tried worked, so this'll have to do for now.
If anyone can get a cleaner solution I'd be happy to hear it.
Cheers for the help. :)