Thread: Add Menu Item
View Single Post
04/01/17, 08:26 AM   #2
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
Hi msfighter. Welcome to ESOUI!

In order to add new context menu items you first need to find a hook point where you can run your addon's code. The guild context menu is generated in guildroster_keyboard.lua starting from line 181. In the last line you can see that self:ShowMenu(control) is called. Which means you can prehook that method and then add your entries inbetween the ingame code's creation of menu entries and the actual code to show the menu like this:

Lua Code:
  1. ZO_PreHook(GUILD_ROSTER_KEYBOARD, "ShowMenu", function()
  2.     -- add your entry here like this:
  3.     AddCustomMenuItem("MyLabel", function()
  4.         -- the click handler
  5.     end)
  6. end)

Instead of calling AddMenuItem directly, you should always use the method AddCustomMenuItem provided by LibCustomMenu in order to prevent seemingly unrelated "secure code violation" errors in other parts of the UI.
  Reply With Quote