View Single Post
04/26/23, 09:42 AM   #23
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,000
ZO_Menu is the context menu TLC and ZO_MenuItemn is 1 item in the context menu.
It's correct that you see those.

But also here applies: This is reused in MANY other vanilla code and addons so do not change ZO_MenuItem etc. !as this is rebuild each time! you right click any control and ShowMenu(control) is called!

You need to find the correct "build of those context menus, before ShowMenu is called, for the guild, friend lists and change the code there. If you change it at ZO_Menu (which you won't be able to do as the context menu was build already and the callback functions that are called as you click on one ZO_MenuItem is already there) you most probably get into similar trouble as before AND will break even more addons

So what you need to do is reverse engineering as described in one of my other posts.
Use ZGOO or merTorchbug to get the control below the mouse before the context menu opens.
This will be a ZO_FriendsListRow1 or whatever then
Search for that control's parent e.g. ZO_FreindsList
Then check where in teh vanilla code the AddMenuItem or ShowMenu functions are used and read the code how the lines for the context menu are build there.
You will find a function that you need to overwritte or change then AND it must bea global function, no local (as you cannot access those).

ZO_KeyboardFriendsListManager:FriendsListRow_OnMouseUp(control, button, upInside)
https://github.com/esoui/esoui/blob/...board.lua#L215
-> ZO_KeyboardFriendsListManager is the class, you need to hook into the global object which get's greated via <object> = <className>:New(...)
-> https://github.com/esoui/esoui/blob/...board.lua#L357
-> Object is FRIENDS_LIST

But ZOs also provides a globally acessible function returning that object'S function for you already, which you can easily PreHook and change the context menu accordingly to your needs:
https://github.com/esoui/esoui/blob/...board.lua#L278
ZO_FriendsListRow_OnMouseUp(control, button, upInside)

BUT AGAIN: If you prehook and return true to hide the original context menu etc. you will maybe destroy other addons or even vanilla code.
You would have to rebuild ALL code from function ZO_KeyboardFriendsListManager:FriendsListRow_OnMouseUp(control, button, upInside) and just replace the context menu entry for "Jump to friend" with yours! So you cannot simply "just replace 1 entry" in there. You need to redefine that function basically....

So do this with care and MUCH testing (this would also be a relief for us who need to check your files and update them every day several times I recommand to change your code and TEST it for a few days before updating the addon each time... Thank you).



Most of the lists like friends list etc. are also suported by LibcustomMenu afaik so instead of altering the original menu entry and trying to overwrite or change it, maybe just try to add a new entry which teleports AND runs your code then? And keep the existing entry where it is?

Last edited by Baertram : 04/26/23 at 12:54 PM.
  Reply With Quote