Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
WoW
Talk
English
Views
Read
Edit
History
More
Search
Navigation
Home
Random page
Help using wiki
Editions
for WoW
for WildStar
for Solar2D
Documentation
for WoW
for WildStar
Reference
WoW
⦁ FrameXML
⦁ AddOns
⦁ API
⦁ WoW Lua
WildStar
⦁ AddOns
⦁ API
⦁ WildStar Lua
Engine
Tools
What links here
Related changes
Special pages
Page information
Site
Recent Changes
Editing
WoW:Using UIDropDownMenu
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Step 3 : Initialization == If you skipped [[#Step 2 : The Menu]], you must add an ''OnLoad'' function to your button in the following fashion. This will display the menu in the first style specified in [[#Step 1 : The Button]]. <Frame parent="UIParent"> <Frames> <Button name="MyDropDownMenuButton"> <Scripts> <OnLoad> UIDropDownMenu_Initialize(self, MyDropDownMenu_OnLoad); </OnLoad> <OnClick> MyDropDownMenuButton_OnClick(); </OnClick> </Scripts> </Button> </Frames> </Frame> As you have seen from the example, the third variable in ''UIDropDownMenu_Initialize'' changes the appearance of the menu. If the third variable is nil, the menu will be displayed in the fashion of the first example shown in [[#Step 1 : The Button]]. If the third variable is "MENU", which requires the initialization to occur in a separate frame outside of the button as shown in [[#Step 2 : The Menu]], the menu will be displayed in the fashion of the second example shown in [[#Step 1 : The Button]]. The ''OnLoad'' function itself should be as follows. This example adds one option to the menu. function MyDropDownMenu_OnLoad() info = {}; info.text = "This is an option in the menu."; info.value = "OptionVariable"; info.func = FunctionCalledWhenOptionIsClicked -- can also be done as function() FunctionCalledWhenOptionIsClicked() end; -- Add the above information to the options menu as a button. UIDropDownMenu_AddButton(info); end Note that careless use of throw-away tables can make your addon generate a lot of unnecessary memory garbage. This is especially true I you don't create menu only once, but recreate it dynamically every time it is displayed to place check marks or any other dynamic content where it needed. See [[HOWTO: Use Tables Without Generating Extra Garbage]] for some advices on how to minimize or eliminate completely garbage generation in such cases.
Summary:
Please note that all contributions to AddOn Studio are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
AddOn Studio Wiki:Copyrights
for details).
Submissions must be written by you, or copied from a public domain or similar free resource (see
AddOn Studio Wiki:Copyrights
for details).
Cancel
Editing help
(opens in new window)