Thread Tools Display Modes
09/19/14, 01:52 PM   #1
mattmillus
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 13
Hooking ZO_Tooltip:LayoutItem

I am trying to create a more powerful/graceful way of modifying item tooltips than PreHooking the OnShow and OnUpdate methods (which seems to be what most devs do).

I found this function inside itemtooltips.lua:
function ZO_Tooltip:LayoutItem(itemLink, equipped, creatorName)

This seems to be the perfect place to post-hook in - its the function that branches based on the item type and then draws all of the tooltips rows. However I do not seem to be able to hook the function using the same technique I used for other class functions (such as for hooking GUILD_ROSTER.CompareGuildMembers).

I do:
local origLayoutItem
local function myLayoutItem(self, itemLink, equipped, creatorName) d("HIT") end

and then I tried both:
1)
origLayoutItem = ItemTooltip.LayoutItem
ItemTooltip.LayoutItem = myLayoutItem

and 2)
origLayoutItem = ZO_Tooltip.LayoutItem
ZO_Tooltip.LayoutItem = myLayoutItem

But I cant get my debug to hit. Is this entire function truly not called by the game, or am I doing something wrong with the class object? Could it be a private function or something, how would I tell?

Any help appreciated!
  Reply With Quote
09/19/14, 02:09 PM   #2
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
The problem is that even if this method exists, it is never called from within the default UI code, so hooking wont do anything. If you want to modify tooltips, you have to hook methods which are actually used.
  Reply With Quote
09/19/14, 02:24 PM   #3
mattmillus
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 13
Thanks Garkin!

But how do you know the function isnt used, have you looked at this case in the past? Seems odd that the entire itemtooltips.lua file would be unused, unless its a work in progress for gamepad support or something..?

Is a prehook like follows your preferred method?
ZO_PreHookHandler(ItemTooltip, 'OnShow',function (control) onTooltipShow(control) end)
ZO_PreHookHandler(ItemTooltip, 'OnHide', function (control) onTooltipHide(control) end)

EDIT:
Is the entire ZO_Tooltip class unused? How do I get a handle to objects of this class? It is not the same as the global ItemTooltip control

Last edited by mattmillus : 09/19/14 at 02:49 PM.
  Reply With Quote
09/19/14, 02:59 PM   #4
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
I only found ZO_Tooltip used in
EsoUI/Ingame/Skills/GamepadSkills.lua +404 ZO_Tooltip:Initialize(self.selectedTooltip)
EsoUI/Ingame/Inventory/GamepadInventory.lua +419 ZO_Tooltip:Initialize(self.equippedTooltip)
EsoUI/Ingame/Inventory/GamepadInventory.lua +425 ZO_Tooltip:Initialize(self.selectedTooltip)

Plus, it's not even a "class" in the sense "derived from ZO_Object", it's just a table.
ZO_Tooltip:Initialize(control) mixes ZO_TooltipStyledObject, ZO_TooltipSection, ZO_Tooltip into the control, so rewriting ZO_Tooltip*.* later will have no effect.

ItemTooltip as well as other core tooltip objects have no connection to ZO_Tooltip afaict.
  Reply With Quote
09/19/14, 03:15 PM   #5
mattmillus
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 13
So I found this thread: http://www.esoui.com/forums/showthread.php?p=10485

And it seems that the entire ZO_Tooltip class wasnt added until 1.3, as its listed under 'new tables' there.

I then used grep to search the entire lua directory structure for "ZO_Tooltip" (with whole word and case filtering on), and the only files that reference this class are gamepadinventory.lua and gamepadskills.lua, so I was actually correct - this class is a work in progress for gamepad support and isnt functional yet. Too bad =(

EDIT: Thanks merlight, didnt see your reply until I had posted! I came to the exact same conclusions!
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Hooking ZO_Tooltip:LayoutItem


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off