m
Move page script moved page API EasyMenu to WoW:API EasyMenu without leaving a redirect
(→Example: single block of code) |
m (Move page script moved page API EasyMenu to WoW:API EasyMenu without leaving a redirect) |
||
| (6 intermediate revisions by 5 users not shown) | |||
| Line 19: | Line 19: | ||
The following example creates a context menu based on a table description: | The following example creates a context menu based on a table description: | ||
local menu = { | local menu = { | ||
{ text = "Select an Option", isTitle = true}, | |||
{ text = "Option 1", func = function() print("You've chosen option 1"); end }, | |||
{ text = "Option 2", func = function() print("You've chosen option 2"); end }, | |||
{ text = "More Options", hasArrow = true, | |||
menuList = { | |||
{ text = "Option 3", func = function() print("You've chosen option 3"); end } | |||
} | |||
} | |||
} | } | ||
local menuFrame = CreateFrame("Frame", "ExampleMenuFrame", UIParent, "UIDropDownMenuTemplate") | local menuFrame = CreateFrame("Frame", "ExampleMenuFrame", UIParent, "UIDropDownMenuTemplate") | ||
-- Make the menu appear at the cursor: | -- Make the menu appear at the cursor: | ||
EasyMenu( | EasyMenu(menu, menuFrame, "cursor", 0 , 0, "MENU"); | ||
-- Or make the menu appear at the frame: | -- Or make the menu appear at the frame: | ||
menuFrame:SetPoint("Center", UIParent, "Center") | |||
EasyMenu( | EasyMenu(menu, menuFrame, menuFrame, 0 , 0, "MENU"); | ||
==Notes== | |||
* You <i>must</i> give the frame a name (argument 2 to {{api|CreateFrame}}()) for menus to work. | |||
== See Also == | == See Also == | ||
* [[UI Object UIDropDownMenu]] | * [[UI Object UIDropDownMenu]] | ||
* [[Using UIDropDownMenu]] | * [[Using UIDropDownMenu]] | ||