Allows to extend Blizzard dropdowns without spreading taint (because the native dropdown code should not be trusted). Also ensures multiple addons extending the same dropdown through this API do not interfere with one another.
DropExtend provides a single method:
LibStub('DropExtend-1.0'):Hook(dropdown, callback)
- dropdown: the frame you wish to extend
- callback: function that will be called each time the dropdown native
initFunc
is executed (see definition), with the same parameterscallback(dropdown, level, menuList)
. Should return a frame you wish to show with the content being initialized, or nil when you have nothing to add.
This code will add content to the Loot Journal class filter dropdown - one frame MyMainLevelExtension
to the dropdown main level, and another frame MyClassListExtension
to the class list:
LibStub('DropExtend-1.0'):Hook(LootJournalItemsClassDropDown, function(dropdown, level, menuList)
if level == 1 then
return MyMainLevelFrame
elseif level == 2 and UIDROPDOWNMENU_MENU_VALUE == CLASS_DROPDOWN then
return MyClassListFrame
end
end)
If you use this library, please list it as one of your dependencies in the CurseForge admin system. It's a big help! 👍