Originally Posted by Shaktar
I have a drop down menu that displays configuration options. Selecting one option should put a checkmark next to that option, deselect some other options, and leave some other options alone, in the same menu. I have not found documentation that shows how this is done after the menu has already been initialized. If this cannot be done after initialization, do I need to make a completely new menu each time someone changes an option?
Here's my code on initializing the menu which works okay. For HandleFirstMenu, I would like it to put a checkmark next to the first selected menu option, de-check the second option, and leave the third option alone.
function InitializeMenu()
info = { };
info.func = HandleFirstMenu;
info.text = 'first';
UIDropDownMenu_AddButton(info);
info.func = HandleSomeOtherMenu;
info.text = 'second';
info.checked = 1;
UIDropDownMenu_AddButton(info);
info.text = 'third';
info.checked = 1;
UIDropDownMenu_AddButton(info);
end;
function HandleMenu()
-- code to check first menu option, uncheck second menu option, and leave third menu option alone
end;
While there is a function called:
function UIDropDownMenuButton_GetChecked()
There is no SetChecked for the UIDropDownMenu.
There is no documentation or example that I could find to show how this is done. Hours of trial and error have gone nowhere. This is the closest I could come up with:
local button = this:GetName();
local check = button .. 'Check';
getglobal(check):Show();
this.checked = 1;
ScriptError() -- if I put this here, the first menu item briefly displays a check while displaying a script error
But next time the menu is used, that check that briefly displayed never appears again.
It appears that without a function called UIDropDownMenuButton_SetChecked(), that I will have to initialize a new menu with different menu items checked (according to current user preferences) each time that the user accesses the drop down menu.
|
I believe (but I'm not sure) that you have to set this.checked during initialization. You can't dynamically update the menu. This is going off the information based here:
http://www.wowwiki.com/HOWTO:_Use_UIDropDownMenu