Adding items to chat context menu
Hi, guys.
I have a question and hope you can help me. I want to add additional item to context menu at chat (when you r-click on player name). I found ingame function to do that, but menu is re-created each time player name is clicked. Lua Code:
I tried to capture event "OnLinkClicked" for all possible chat windows (stored at "ZO_ChatWindow.container.windows"), but there's a problem. ZO_ChatWindow.container is empty untill someone writes sth to chat, so containers inside can't be hooked before that. I's stuck. Only some hacky-business is on my mind. So, any ideas how to add own item to ingame menu? :) |
I have some movements with my question.
1st. Register an event to initialize hooking link clicks Lua Code:
2nd. Hooking itself. Lua Code:
3rd. Function to add item to the end of current list and resise ZO_Menu Lua Code:
But now I have another problem... When I move mouse over new item it does not selects properly. It works sometimes, but I can't repeat it manually. |
here I hook ZO_ChatSystem_OnLinkClicked, call the original ZO_ChatSystem_OnLinkClicked, then hide the menu, add menu items, and show it again, does the job fine here you can test this in my addon
The only drawback of hooking it is that the menu is flagged unprotected, and even CallSecureProtected("ShowMenu", nil, 1) CallSecureProtected("AddMenuItem", COLOR_HAM.."Train as HAM"..COLOR_STOP, function() train(id, false) end) won't work at all But anyway it seems only restricting the "Target player" option which is garbage to me , who targets from a ChatWindow today, and anyway this game is not target friendly, huhu |
Note that EVENT_PLAYER_ACTIVATED fires for every loading screen. After the event fires the first time and you have done what you need to do, you should unregister for this event (unless there is a reason you need to run your code more than once).
|
You can also Unregister the EVENT_ADD_ON_LOADED event in the corresponding handler, saves you some unnecessary calls of the handler (you still need to verify the name though).
|
Thanks Fathis Ules for support!
ShowMenu() done all magic I want to :) And removed hacky-code with "callLater" function. |
Lua Code:
No need to overwrite, hook or detour anything. Both will get called in addition to the unmodified native code, no matter where you click on the Link. Cheers! :) |
Quote:
|
All times are GMT -6. The time now is 12:52 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI