12.07.2015 Views

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 23 ■ <strong>Creating</strong> Dropdown Menus 435basic positioning in<strong>for</strong>mation. The function takes eight possible arguments,but only the first six are typically used:level (number)—The initial level to display. This number is passeddirectly to the initialization function.value—A value used to set the global variable UIDROPDOWNMENU_MENU_VALUE, which is used primarily in multilevel menus. This is discussed indetail later in this chapter.dropDownFrame—The actual dropdown frame to display.anchorName (string)—The name <strong>of</strong> the frame to which the dropdownshould be anchored. This can also be the string cursor, in which case thedropdown is anchored to the cursor position at the moment this functionis called.xOffset (number)—A horizontal <strong>of</strong>fset in units <strong>for</strong> the dropdown menu.yOffset (number)—A vertical <strong>of</strong>fset in units <strong>for</strong> the dropdown menu.Add the following function to DropDownTest.lua to call ToggleDropDownMenu() when the test button is clicked:function DropDownTest_ButtonOnClick(self, button, down)local name = self:GetName()ToggleDropDownMenu(1, nil, DropDownTest_DropDown, name, 0, 0)endBecause this example displays only one level <strong>of</strong> the menu, the functionpasses 1 as the level <strong>and</strong> doesn’t include a menu value. The dropdown will beanchored to the button itself, with no <strong>of</strong>fset from the default location.Testing the DropdownLog in to <strong>World</strong> <strong>of</strong> <strong>Warcraft</strong> with the DropDownTest addon enabled; a gamebutton should display in the center <strong>of</strong> your screen. Click the button <strong>and</strong> youshould see the dropdown menu shown in Figure 23-3.Figure 23-3: Dropdown menu created by the DropDownTest addon

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!