I have found that parts of the UIDropDownMenu can be set up in the XML file. For example,
<Frame name="MyAddOn_Select" inherits="UIDropDownMenuTemplate"> <Anchors> <Anchor point="TOPRIGHT" relativePoint="TOPRIGHT"> <Offset> <AbsDimension x="8" y="-28"/> </Offset> </Anchor> </Anchors> <FontString inherits="ChatFontNormal"/> <Scripts> <OnShow> UIDropDownMenu_SetWidth(240, this); UIDropDownMenu_Initialize(this,MyAddOn_Select_Initialize); </OnShow> </Scripts> </Frame>
The Initialize and Click functions in my AddOn's lua file are much as is on the definition page here. One thing I couldn't find a way to do, though, was to set the origin of the button list shown when you click the DropDown's button; it always wanted to align its TopLeft to the parent's BottomLeft. A more appropriate place for mine would be with right edges aligned.
ClemSnide 09:13, 19 April 2007 (EDT)
This article reads a lot like a HOWTO article... and we've already got one of those on this subject. I think some consolidation and changes to both pages are needed. I've done some work with popup menus, but I wouldn't call myself an expert. Anyone with more experience have any ideas? -- Tuhljin (talk) 20:42, 11 May 2008 (UTC)
Changes in 3.0.2 Edit
Blizzard swap around the args for some of the functions in the UIDropDownMenu.lua to make the first arg always be the reference to the frame object. Because of this, functions such as UIDropDownMenu_SetText() have to be changed from UIDropDownMenu_SetWidth("text", frame) to UIDropDownMenu_SetWidth(frame, "text"). I will edit the article to reflect these new changes.
Here is a list of functions I have found in UIDropDownMenu.lua that have been changed:
- UIDropDownMenu_SetWidth(frame, width, padding)
- UIDropDownMenu_SetButtonWidth(frame, width)
- UIDropDownMenu_SetText(frame, text)
- UIDropDownMenu_JustifyText(frame, justification)