Thread: Event Chaining
View Single Post
04/15/14, 09:34 AM   #11
Vicster0
 
Vicster0's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 82
Originally Posted by Wobin View Post
It doesn't, unfortunately.

You're safer trying to hook closer to the actual source.
Good to know.

I believe I was hooking as close as possible; I configured the prehook for the OnMouseOver handler for the generic ZO_InventorySlot. The problem is that somewhere in ZO's code, where they bind commands to objects for keybind interactions (in this case, pressing 'e' to use an item in the inventory or transfer to and from the bank), the original mouseover handler can call, and in this case, does call, a private/protected function. This would be fine as it's their handler, but once you localize that original handler (for use in a prehooked function, for instance) it becomes part of 'your addon's scope' and thus unsafe code meaning it can no longer run that private/protected function. Or, at least, this is how I am understanding it....

Please do correct me if I am mistaken or missing something!


Lua Code:
  1. INVENTORYSLOT_ORIGINAL_MOUSE_ENTER_HANDLER = ZO_InventorySlot_OnMouseEnter;
  2.  
  3. --OnMouseEnter preHook
  4. ZO_InventorySlot_OnMouseEnter = function( ... )
  5.         -- { my code } --
  6.         INVENTORYSLOT_ORIGINAL_MOUSE_ENTER_HANDLER( ... );
  7. end


I've since changed this code to use an existing mouseover event that I have hooked into as the calling function and utilize the moc() functionality instead, alleviating the issue with the private function.
  Reply With Quote