View Single Post
10-16-11, 02:17 AM   #13
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Originally Posted by Animor View Post
The reason it works like that at any addon is that the list is always closed when you select an option. Any anyway, this is not done by default, you have to uncheck it in the initialize function. By default, you can check more than one item, which is the behavior of some of the dropdown lists.

What I'm trying to do is uncheck other not selected items while the list remains open. I don't know how to access the other options and do that other than through the initialize function.
So, basically something like the Minimap tracking menu? Might be some hints in that code.

Lua Code:
  1. function MiniMapTracking_Update()
  2.     UIDropDownMenu_Refresh(MiniMapTrackingDropDown);
  3. end
  4.  
  5. function MiniMapTrackingDropDown_OnLoad(self)
  6.     UIDropDownMenu_Initialize(self, MiniMapTrackingDropDown_Initialize, "MENU");
  7.     self.noResize = true;
  8. end
  9.  
  10. function MiniMapTracking_SetTracking (self, id, unused, on)
  11.     SetTracking(id, on);
  12.     UIDropDownMenu_Refresh(MiniMapTrackingDropDown);
  13. end
  14.  
  15. function MiniMapTrackingDropDownButton_IsActive(button)
  16.     local name, texture, active, category = GetTrackingInfo(button.arg1);
  17.     return active;
  18. end
  19.  
  20. function MiniMapTrackingDropDown_IsNoTrackingActive()
  21.     local name, texture, active, category;
  22.     local count = GetNumTrackingTypes();
  23.     for id=1, count do
  24.         name, texture, active, category  = GetTrackingInfo(id);
  25.         if (active) then
  26.             return false;
  27.         end
  28.     end
  29.     return true;
  30. end
  31.  
  32. function MiniMapTrackingDropDown_Initialize()
  33.     local name, texture, active, category;
  34.     local count = GetNumTrackingTypes();
  35.     local info;
  36.    
  37.     info = UIDropDownMenu_CreateInfo();
  38.     info.text=MINIMAP_TRACKING_NONE;
  39.     info.checked = MiniMapTrackingDropDown_IsNoTrackingActive;
  40.     info.func = ClearAllTracking;
  41.     info.icon = nil;
  42.     info.arg1 = nil;
  43.     info.isNotRadio = true;
  44.     info.keepShownOnClick = true;
  45.     UIDropDownMenu_AddButton(info);
  46.    
  47.     for id=1, count do
  48.         name, texture, active, category  = GetTrackingInfo(id);
  49.  
  50.         info = UIDropDownMenu_CreateInfo();
  51.         info.text = name;
  52.         info.checked = MiniMapTrackingDropDownButton_IsActive;
  53.         info.func = MiniMapTracking_SetTracking;
  54.         info.icon = texture;
  55.         info.arg1 = id;
  56.         info.isNotRadio = true;
  57.         info.keepShownOnClick = true;
  58.         if ( category == "spell" ) then
  59.             info.tCoordLeft = 0.0625;
  60.             info.tCoordRight = 0.9;
  61.             info.tCoordTop = 0.0625;
  62.             info.tCoordBottom = 0.9;
  63.         else
  64.             info.tCoordLeft = 0;
  65.             info.tCoordRight = 1;
  66.             info.tCoordTop = 0;
  67.             info.tCoordBottom = 1;
  68.         end
  69.         UIDropDownMenu_AddButton(info);
  70.     end
  71. end
  Reply With Quote