Originally Posted by Animor
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:
function MiniMapTracking_Update()
UIDropDownMenu_Refresh(MiniMapTrackingDropDown);
end
function MiniMapTrackingDropDown_OnLoad(self)
UIDropDownMenu_Initialize(self, MiniMapTrackingDropDown_Initialize, "MENU");
self.noResize = true;
end
function MiniMapTracking_SetTracking (self, id, unused, on)
SetTracking(id, on);
UIDropDownMenu_Refresh(MiniMapTrackingDropDown);
end
function MiniMapTrackingDropDownButton_IsActive(button)
local name, texture, active, category = GetTrackingInfo(button.arg1);
return active;
end
function MiniMapTrackingDropDown_IsNoTrackingActive()
local name, texture, active, category;
local count = GetNumTrackingTypes();
for id=1, count do
name, texture, active, category = GetTrackingInfo(id);
if (active) then
return false;
end
end
return true;
end
function MiniMapTrackingDropDown_Initialize()
local name, texture, active, category;
local count = GetNumTrackingTypes();
local info;
info = UIDropDownMenu_CreateInfo();
info.text=MINIMAP_TRACKING_NONE;
info.checked = MiniMapTrackingDropDown_IsNoTrackingActive;
info.func = ClearAllTracking;
info.icon = nil;
info.arg1 = nil;
info.isNotRadio = true;
info.keepShownOnClick = true;
UIDropDownMenu_AddButton(info);
for id=1, count do
name, texture, active, category = GetTrackingInfo(id);
info = UIDropDownMenu_CreateInfo();
info.text = name;
info.checked = MiniMapTrackingDropDownButton_IsActive;
info.func = MiniMapTracking_SetTracking;
info.icon = texture;
info.arg1 = id;
info.isNotRadio = true;
info.keepShownOnClick = true;
if ( category == "spell" ) then
info.tCoordLeft = 0.0625;
info.tCoordRight = 0.9;
info.tCoordTop = 0.0625;
info.tCoordBottom = 0.9;
else
info.tCoordLeft = 0;
info.tCoordRight = 1;
info.tCoordTop = 0;
info.tCoordBottom = 1;
end
UIDropDownMenu_AddButton(info);
end
end