Thread Tools Display Modes
Prev Previous Post   Next Post Next
12-31-22, 09:08 AM   #1
Benalish
A Flamescale Wyrmkin
 
Benalish's Avatar
Join Date: Dec 2012
Posts: 123
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:

Lua Code:
  1. local main = CreateFrame("Frame", nil, UIParent)
  2. main:SetSize(200, 100)
  3. main:SetPoint("CENTER")
  4. main:SetFrameStrata("HIGH")
  5. local backdrop = {
  6.     bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
  7.     edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
  8.     tile = true,
  9.     tileSize = 8,
  10.     edgeSize = 16,
  11.     insets = {
  12.         left = 3,
  13.         right = 3,
  14.         top = 3,
  15.         bottom = 3
  16.     }
  17. }
  18. main:SetBackdrop(backdrop)
  19.  
  20. main.conditions = CreateFrame("Frame", nil, main, "combobox_template")
  21. main.conditions:SetSize(125,25)
  22. main.conditions:SetPoint("CENTER")
  23.  
  24. function flag_dd_OnLoad(frame, level, menuList)
  25.     local info = UIDropDownMenu_CreateInfo()
  26.     info.text = "Blue Pill"
  27.     UIDropDownMenu_AddButton(info)
  28.     info.text = "Red Pill"
  29.     UIDropDownMenu_AddButton(info)
  30.  end
  31.  
  32. function flag_dd_OnClick()
  33.     ToggleDropDownMenu(1, nil, flag_dd, "cursor", 0, 0);
  34. end

Last edited by Benalish : 01-02-23 at 11:43 AM.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » UIDropDownMenu doesn't show


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