Thread Tools Display Modes
Prev Previous Post   Next Post Next
05-13-22, 01:42 PM   #1
Limbopo
A Defias Bandit
Join Date: May 2022
Posts: 2
Unhappy Background of DropDown menu

Hello.
For example we have this dropdown menu.


Lua Code:
  1. HWGA = {}
  2.  
  3. HWGA.Checkboxes = {
  4.    title = "Select checkboxes",
  5.    menu = {
  6.       Key_1 = "Value 1",
  7.       Key_2 = "Value 2",
  8.       Key_3 = "Value 3",
  9.       Key_4 = "Value 4",
  10.       Key_5 = "Value 5",
  11.    }
  12. }
  13.  
  14. HWGA.ActiveCheckboxes = {}
  15.  
  16.  
  17. function HWGADropDown_SetFlag(self, flag_name)
  18.    if HWGA.ActiveCheckboxes[flag_name] then
  19.       HWGA.ActiveCheckboxes[flag_name] = nil;
  20.       self.checked = false;
  21.    else
  22.       HWGA.ActiveCheckboxes[flag_name] = true;
  23.       self.checked = true;
  24.    end
  25. end
  26.  
  27. function HWGADropDown_Initialize(self)
  28.    local info = UIDropDownMenu_CreateInfo();
  29.    
  30.    info.text = HWGA.Checkboxes .title;
  31.    info.isTitle = true;
  32.    info.notCheckable = true;
  33.    UIDropDownMenu_AddButton(info);
  34.    
  35.    for flag_name, flag_value in pairs(HWGA.Checkboxes.menu) do
  36.       info = UIDropDownMenu_CreateInfo();
  37.       info.text = flag_name;
  38.       info.value = flag_value;
  39.       info.checked = HWGA.ActiveCheckboxes[flag_name];
  40.       info.func = HWGADropDown_SetFlag;
  41.       info.arg1 = flag_name;
  42.       info.isNotRadio = true;
  43.       info.keepShownOnClick = true;
  44.       UIDropDownMenu_AddButton(info);
  45.    end
  46. end
  47.  
  48. local drp_dwn_button = CreateFrame("Button", "HereWeGoAgainDropDownButton", UIParent, "TooltipBackdropTemplate");
  49. drp_dwn_button:SetSize(200, 40);
  50. drp_dwn_button:SetPoint("CENTER", UIParent, "CENTER", 0, 0);
  51. drp_dwn_button:SetScript("OnMouseDown", function(self) ToggleDropDownMenu(1, nil, HereWeGoAgainMenuDropDown, self, 0, 0) end);
  52.  
  53. local text = drp_dwn_button:CreateFontString(nil, "OVERLAY", "GameFontNormal");
  54. text:SetPoint("CENTER", drp_dwn_button, "CENTER", 0, 0);
  55. text:SetText(HWGA.Checkboxes.title);
  56.  
  57. local drp_dwn_frame = CreateFrame("Frame", "HereWeGoAgainMenuDropDown", nil, "UIDropDownMenuTemplate");
  58. UIDropDownMenu_Initialize(drp_dwn_frame, HWGADropDown_Initialize, "MENU")

Is there is any simple way to change background color/opacity only for this dropdown?
In example, I want this:


I've found only one way to do it, but it changes every dropdown in a game, because it's in dependecies with DropDownList:
Lua Code:
  1. local BlackLayout = {
  2.         ["TopRightCorner"] = {atlas = "Tooltip-NineSlice-CornerTopRight"},
  3.         ["TopLeftCorner"] = {atlas = "Tooltip-NineSlice-CornerTopLeft"},
  4.         ["BottomLeftCorner"] = {atlas = "Tooltip-NineSlice-CornerBottomLeft"},
  5.         ["BottomRightCorner"] = {atlas = "Tooltip-NineSlice-CornerBottomRight"},
  6.         ["TopEdge"] = {atlas = "_Tooltip-NineSlice-EdgeTop"},
  7.         ["BottomEdge"] = {atlas = "_Tooltip-NineSlice-EdgeBottom"},
  8.         ["LeftEdge"] = {atlas = "!Tooltip-NineSlice-EdgeLeft"},
  9.         ["RightEdge"] = {atlas = "!Tooltip-NineSlice-EdgeRight"},
  10.         ["Center"] = {layer = "BACKGROUND", atlas = "ui-frame-party-backgroundtile", x = -4, y = 4, x1 = 4, y1 = -4}
  11.     }
  12.  
  13.     NineSliceUtil.ApplyLayout(DropDownList1MenuBackdrop, BlackLayout )

I didn't find any similar threads, but it seems to me that this question was of interest to many people.

I've tried SetBackdrop/different layouts, but it is not working. What I'm doing wrong?
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Background of 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