Thread Tools Display Modes
Prev Previous Post   Next Post Next
05-29-22, 08:54 AM   #1
Sweetsour
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Dec 2014
Posts: 130
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:
  1. function WardrobeFilterDropDown_InitializeBaseSets(self, level)
  2.             local filterSystem = {
  3.                 onUpdate = WardrobeResetFiltersButton_UpdateVisibility,
  4.                 filters = {
  5.                     { type = FilterComponent.Checkbox, text = COLLECTED, filter = LE_TRANSMOG_SET_FILTER_COLLECTED, set = WardrobeFilterDropDown_SetBaseSetCollectedShown, isSet = WardrobeFilterDropDown_GetBaseSetCollectedShown },
  6.                     { type = FilterComponent.Checkbox, text = NOT_COLLECTED, filter = LE_TRANSMOG_SET_FILTER_UNCOLLECTED, set = WardrobeFilterDropDown_SetBaseSetUncollectedShown, isSet = WardrobeFilterDropDown_GetBaseSetUncollectedShown },
  7.                     { type = FilterComponent.Separator },
  8.                     { type = FilterComponent.Checkbox, text = TRANSMOG_SET_PVE, filter = LE_TRANSMOG_SET_FILTER_PVE, set = WardrobeFilterDropDown_SetBaseSetPVEShown, isSet = WardrobeFilterDropDown_GetBaseSetPVEShown },
  9.                     { type = FilterComponent.Checkbox, text = TRANSMOG_SET_PVP, filter = LE_TRANSMOG_SET_FILTER_PVP, set = WardrobeFilterDropDown_SetBaseSetPVPShown, isSet = WardrobeFilterDropDown_GetBaseSetPVPShown },
  10.                    
  11.                     { type = FilterComponent.Separator },
  12.                 },
  13.             };
  14.             FilterDropDownSystem.Initialize(self, filterSystem, level);
  15.         end

This is the first attempt. It worked but some of the new buttons were indented while others weren't.
Lua Code:
  1. function(e,addonName)
  2.     if (e ~= "ADDON_LOADED") then
  3.         return
  4.     end
  5.    
  6.     if (addonName == "Blizzard_Collections") then
  7.         WardrobeCollectionFrame.FilterButton:HookScript("OnMouseUp",
  8.             function(self,button)
  9.                 UIMenu_AddButton(DropDownList1,"New Button",nil,function() print("Clicked New Button!") end,false)    
  10.         end)
  11.     end
  12. end

This is another attempt that I tried based on online documentation but was unsuccessful:
Lua Code:
  1. function(e,addonName)
  2.     if (e ~= "ADDON_LOADED") then
  3.         return
  4.     end
  5.    
  6.     if (addonName == "Blizzard_Collections") then
  7.         UIDropDownMenu_Initialize(WardrobeFilterDropDown, WardrobeFilterDropDown_Initialize, "MENU");
  8.         UIDropDownMenu_AddSeparator()
  9.         local info = UIDropDownMenu_CreateInfo();
  10.        
  11.         info.text = "New Button";
  12.         info.isTitle = true;
  13.         info.notCheckable = true;
  14.         UIDropDownMenu_AddButton(info, 1);
  15.     end
  16. end
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Trying to add buttons to dropdown menu.


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