Thread Tools Display Modes
11/04/14, 02:32 PM   #1
Randactyl
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 251
IGV causing generic UI bug

Have a problem with Inventory Grid View causing withdraw/deposit to fail with this message:



It's because of this code:

Lua Code:
  1. --postHook function for "ZO_InventorySlot_OnMouseEnter"
  2. --Sets the ItemTooltip owner and offset so that tooltips always appear at the
  3. --beginning of a gridded row.
  4. local function ReinitializeTooltip(inventorySlot)
  5.     local isGrid = inventorySlot.isGrid
  6.     if isGrid == true then
  7.         local gridSize = InventoryGridViewSettings:GetGridSize()
  8.         local col = ((inventorySlot:GetLeft() - 1432) / gridSize) + 1
  9.         local offsetX = -(gridSize * col - gridSize)
  10.  
  11.         ItemTooltip:SetOwner(inventorySlot, RIGHT, offsetX, 0)
  12.     end
  13. end
  14.  
  15. --implementation of general postHook found on ESOUI specific to IGV's purposes
  16. local function IGV_OnMouseEnter_postHook(funcName, callback)
  17.     --"ZO_InventorySlot_OnMouseEnter" is being hooked
  18.     local tmp = _G[funcName]
  19.     _G[funcName] = function(...)
  20.         --ZO_InventorySlot_OnMouseEnter returns true if a tooltip was
  21.         --successfully shown, false if a tooltip was hidded.
  22.         local returnValue = tmp(...)
  23.         if(returnValue == true) then
  24.             --make ZO_InventorySlot_OnMouseEnter's arguments availible to
  25.             --my function.
  26.             callback(...)
  27.         end
  28.         return returnValue
  29.     end
  30. end
  31.  
  32. IGV_OnMouseEnter_postHook("ZO_InventorySlot_OnMouseEnter", ReinitializeTooltip)

But I'm not sure why. Any ideas?
I need to head to class, but this is all I'll be thinking about
  Reply With Quote
11/04/14, 03:06 PM   #2
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
/reloadui
I've been getting this message for months now, 3 out of 10 logins. And I never even used IGV.
  Reply With Quote
11/04/14, 03:18 PM   #3
Randactyl
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 251
Yeah, I've gotten it plenty of times before this code was written. However this for some reason causes the error 100% of the time :/
  Reply With Quote
11/04/14, 06:46 PM   #4
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Ok now I actually read the code. I'm sure this error has something to do with right-click menu actions and keybind actions (they're implemented by the same class). This IGV_OnMouseEnter_postHook looks like it wraps the original handler, so that the original - which generates the list of actions - is now being called from add-on code (and those actions are mostly anonymous functions with add-on code in their closure now), making it ineligible to call protected functions directly.

Since this hook only needs to adjust tooltip placement, it should probably be done via customTooltipAnchor:
Lua Code:
  1. -- from ZO_InventorySlot_OnMouseEnter
  2.             if buttonPart.customTooltipAnchor then
  3.                 buttonPart.customTooltipAnchor(tooltipUsed, buttonPart, ComparativeTooltip1, ComparativeTooltip2)
  4.             else
  5.                 ZO_Tooltips_SetupDynamicTooltipAnchors(tooltipUsed, buttonPart.tooltipAnchor or buttonPart, ComparativeTooltip1, ComparativeTooltip2)
  6.             end

Here's a possible replacement, untested (I still haven't bothered to get IGV):
Lua Code:
  1. local function igvTooltipAnchor(tooltip, inventorySlot, comparativeTooltip1, comparativeTooltip2)
  2.     -- call the regular one, not ideal but probably better than copying most of the code here :)
  3.     ZO_Tooltips_SetupDynamicTooltipAnchors(tooltip, inventorySlot, comparativeTooltip1, comparativeTooltip2)
  4.     -- custom setup
  5.     if inventorySlot.isGrid then
  6.         local gridSize = InventoryGridViewSettings:GetGridSize()
  7.         local col = ((inventorySlot:GetLeft() - 1432) / gridSize) + 1
  8.         local offsetX = -(gridSize * col - gridSize)
  9.         tooltip:SetOwner(inventorySlot, RIGHT, offsetX, 0)
  10.     end
  11. end
  12.  
  13. -- I guess there's some place all inventory slots get that isGrid flag,
  14. -- so add the custom placement handler there:
  15. inventorySlot.customTooltipAnchor = igvTooltipAnchor
  Reply With Quote
11/04/14, 07:16 PM   #5
Randactyl
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 251
Thanks, merlight I'll test it out.

That tooltip anchor edit was the first to work in a long line of ideas. I just went with it when it started working

Edit:

It looks like what you cooked up should work. Though, it seems like offsetX is always -4 which ultimately defeats the purpose of having a varying offset so that the tooltip always shows at the end of the row.

I'm too tired to mess with this now. I'll get back to it tomorrow.
Thanks again for the help!

Last edited by Randactyl : 11/04/14 at 11:43 PM.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » IGV causing generic UI bug

Thread Tools
Display Modes

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