I posted this somewhere else as an example of changing the player (SELF) unit menu but...
So here 'tis again.
/tst to toggle wether the menu adds the entries at the top.
Lua Code:
local XXX
Menu.ModifyMenu("MENU_UNIT_SELF", function(ownerRegion, rootDescription, contextData)
-- Append a new section to the end of the menu.
rootDescription:CreateDivider()
rootDescription:CreateTitle("My New End Section")
rootDescription:CreateButton("|TInterface\\ICONS\\ClassIcon_Evoker:16:16|t Appended button", function() print("Clicked the appended button!") end)
-- Create a button to be a flyout sub-menu
local submenu = rootDescription:CreateButton("Sub-Menu")
-- adding these buttons makes submenu a flyout
submenu:CreateButton("Enable", function(self)
print("Click Enable")
end)
submenu:CreateButton("Disable", function(self)
print("Click Disable")
end)
-- Insert a new section at the start of the menu.
if XXX then
local title = MenuUtil.CreateTitle("My New Top Section")
rootDescription:Insert(title, 1)
local button = MenuUtil.CreateButton("Top button", function() print("Clicked the inserted button!") end)
rootDescription:Insert(button, 2)
local divider = MenuUtil.CreateDivider()
rootDescription:Insert(divider, 3)
end
end)
SLASH_TESTMENU1 = "/tst" -- toggle hiding/showing top menu insert
SlashCmdList.TESTMENU = function(msg)
XXX = not XXX
end
Change: "MENU_UNIT_SELF" to "MENU_UNIT_TARGET" to change the menu for a target unit NPC or see the code
in the TargetFrame_OpenMenu function to see the other target menu options.