12-31-22, 09:08 AM | #1 |
UIDropDownMenu doesn't show
The goal is create a custom combobox template, where the dropdown menu appears with the click on the button. I followed this guide, but the UIDropDownMenu is not shown when button is clicked.
XML code: Code:
<Frame name="combobox_template" virtual="true"> <Size x="1" y="1" /> <Frames> <EditBox name="$parentEditbox" parentKey="editbox"> <Size x="125" y="18" /> <Anchors> <Anchor point="CENTER" > <Offset> <AbsDimension x="27" y="5"/> </Offset> </Anchor> </Anchors> <Backdrop bgFile="Interface\Buttons\WHITE8X8" edgeFile="Interface\Buttons\WHITE8X8" tile="true"> <EdgeSize> <AbsValue val="1"/> </EdgeSize> </Backdrop> <Scripts> <OnLoad> self:SetBackdropColor(0, 0, 0, 0.75) self:SetBackdropBorderColor(0.3, 0.3, 0.3, 1) self:EnableMouse(false) self:EnableKeyboard(false) </OnLoad> </Scripts> <Frames> <Button name="$parentButton" parentKey="button" enableMouse="true"> <Size> <AbsDimension x="25" y="25"/> </Size> <Anchors> <Anchor point="RIGHT" relativeTo="$parent" relativePoint="RIGHT"> <Offset x="3" y="0"/> </Anchor> </Anchors> <Scripts> <OnMouseDown> flag_dd_OnClick() </OnMouseDown> </Scripts> <HighlightTexture file="Interface/Buttons/UI-Common-MouseHilight" alphaMode="ADD"/> <NormalTexture file="Interface/CHATFRAME/UI-ChatIcon-ScrollDown-Up" setAllPoints="true"/> <PushedTexture file="Interface/CHATFRAME/UI-ChatIcon-ScrollDown-Down" setAllPoints="true"/> </Button> <Frame name="flag_dd" inherits="UIDropDownMenuTemplate"> <Scripts> <OnLoad> UIDropDownMenu_Initialize(self, flag_dd_OnLoad, "MENU"); </OnLoad> </Scripts> </Frame> </Frames> </EditBox> </Frames> </Frame> Lua Code:
Last edited by Benalish : 01-02-23 at 11:43 AM. |
|
01-26-23, 03:48 PM | #2 |
One issue I can see is that the guide you are using is from the old wowwiki archives.
Sadly, a lot on that website is outdated and no longer working. I suggest instead to use https://wowpedia.fandom.com Here is their more up to date guide on a dropdown menu: https://wowpedia.fandom.com/wiki/Using_UIDropDownMenu If you follow that guide, should be able to get a working version. (the code from their guide) Code:
local favoriteNumber = 42 -- A user-configurable setting -- Create the dropdown, and configure its appearance local dropDown = CreateFrame("FRAME", "WPDemoDropDown", UIParent, "UIDropDownMenuTemplate") dropDown:SetPoint("CENTER") UIDropDownMenu_SetWidth(dropDown, 200) UIDropDownMenu_SetText(dropDown, "Favorite number: " .. favoriteNumber) -- Create and bind the initialization function to the dropdown menu UIDropDownMenu_Initialize(dropDown, function(self, level, menuList) local info = UIDropDownMenu_CreateInfo() if (level or 1) == 1 then -- Display the 0-9, 10-19, ... groups for i=0,4 do info.text, info.checked = i*10 .. " - " .. (i*10+9), favoriteNumber >= i*10 and favoriteNumber <= (i*10+9) info.menuList, info.hasArrow = i, true UIDropDownMenu_AddButton(info) end else -- Display a nested group of 10 favorite number options info.func = self.SetValue for i=menuList*10, menuList*10+9 do info.text, info.arg1, info.checked = i, i, i == favoriteNumber UIDropDownMenu_AddButton(info, level) end end end) -- Implement the function to change the favoriteNumber function dropDown:SetValue(newValue) favoriteNumber = newValue -- Update the text; if we merely wanted it to display newValue, we would not need to do this UIDropDownMenu_SetText(dropDown, "Favorite number: " .. favoriteNumber) -- Because this is called from a sub-menu, only that menu level is closed by default. -- Close the entire menu with this next call CloseDropDownMenus() end |
|
WoWInterface » Developer Discussions » Lua/XML Help » UIDropDownMenu doesn't show |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|