Thread Tools Display Modes
03-26-07, 03:05 PM   #1
Shaktar
A Kobold Labourer
AddOn Author - Click to view addons
Join Date: Mar 2007
Posts: 1
Possible to check menu options after initialization?

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.
  Reply With Quote
04-07-07, 02:15 AM   #2
Shirik
Blasphemer!
Premium Member
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2007
Posts: 818
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
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Possible to check menu options after initialization?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off