05-29-22, 08:54 AM | #1 |
Trying to add buttons to dropdown menu.
Hello, everyone!
I've been trying to add new buttons to the Wardrobe sets filter dropdown menu. I have had little success thus far and figure I'd reach out to see if anyone could help. I should add that I'm attempting to do this through WeakAuras, to act like a plug-in. I found the code that adds the existing filter options in the wardrobe set filter dropdown menu. The id of the dropdown menu is "WardrobeFilterDropDown". That code is below: Lua Code:
This is the first attempt. It worked but some of the new buttons were indented while others weren't. Lua Code:
This is another attempt that I tried based on online documentation but was unsuccessful: Lua Code:
|
|
05-31-22, 12:48 PM | #2 |
Hi-
There is a lot to unpack here. First I should say I am not familiar with WeakAuras but am familiar with drop downs. You first attempt of a post hook was close. However the routine to hook could be WardrobeFilterDropDown_InitializeBaseSets. It just builds the drop down on the fly as needed on mouse down per the Blizzard XML. Hooking the mouse click may be too 'late' or be inconsistent in behavior. Possibly use hooksecurefunc("WardrobeFilterDropDown_InitializeBaseSets", <your routine>) By the way, the Blizzard code I see in Blizzard_Wardrobe.lua is below. If the example code is from another addon, it could be tricky. The technique should work but the example appears to use a specialized library / utility that may do something to hinder a hook. Code:
function WardrobeFilterDropDown_InitializeBaseSets(self, level) local info = UIDropDownMenu_CreateInfo(); info.keepShownOnClick = true; info.isNotRadio = true; info.text = COLLECTED; info.func = function(_, _, _, value) C_TransmogSets.SetBaseSetsFilter(LE_TRANSMOG_SET_FILTER_COLLECTED, value); end info.checked = C_TransmogSets.GetBaseSetsFilter(LE_TRANSMOG_SET_FILTER_COLLECTED); UIDropDownMenu_AddButton(info, level); ... Code:
function <your routine>(self, level) UIDropDownMenu_AddSeparator() local info = UIDropDownMenu_CreateInfo(); info.text = "New Button"; info.isTitle = true; info.notCheckable = true; UIDropDownMenu_AddButton(info, 1); end You may want to wait until the event(e) == PLAYER_ENTERING_WORLD to ensure all addons are loaded or the hook could fail. |
|
06-02-22, 08:24 PM | #3 |
Wow, that was incredibly easy! Thank you for pointing me in the right direction!
|
|
WoWInterface » Developer Discussions » Lua/XML Help » Trying to add buttons to dropdown menu. |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|