WoW:API EasyMenu: Difference between revisions

m
Move page script moved page API EasyMenu to WoW:API EasyMenu without leaving a redirect
(very useful note. please don't remove)
m (Move page script moved page API EasyMenu to WoW:API EasyMenu without leaving a redirect)
 
(5 intermediate revisions by 4 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 = "Select an Option", isTitle = true},
  { text = "Option 1", func = function() print("You've chosen option 1"); end },
    { 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 = "Option 2", func = function() print("You've chosen option 2"); end },
  { text = "More Options", hasArrow = true,
    { text = "More Options", hasArrow = true,
    menuList = {
        menuList = {
    { text = "Option 3", func = function() print("You've chosen option 3"); end }
            { 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(menuList, menuFrame, "cursor", 0 , 0, "MENU");
  EasyMenu(menu, menuFrame, "cursor", 0 , 0, "MENU");
  -- Or make the menu appear at the frame:
  -- Or make the menu appear at the frame:
  menu_frame:SetPoint("Center", UIParent, "Center")
  menuFrame:SetPoint("Center", UIParent, "Center")
  EasyMenu(menuList, menuFrame, menuFrame, 0 , 0, "MENU");
  EasyMenu(menu, menuFrame, menuFrame, 0 , 0, "MENU");


<b>Note:</b> You <i>must</i> give the frame a name (argument 2 to CreateFrame()) for menus to work.
==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]]
Anonymous user