WoWInterface - View Single Post - GameTooltip SetBagItem() not working for bank slots
View Single Post
04-01-19, 03:06 PM   #1
A Frostmaul Preserver
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 283
GameTooltip SetBagItem() not working for bank slots

My Bagnon plugin relys on scanning item tooltips.

However, it seems that
SetBagItem(self:GetBag(), self:GetID())
does have no effect for items in bank slots (self:GetBag() == -1).

I am using this SetHyperlink() workaround, but is there really no proper way?

(Sorry for not providing a minimum working example that would run without Bagnon. Maybe someone can tell me how to hook OnEnter for item slots in general?)

-- Tooltip used for scanning.
local scannerTooltip = CreateFrame("GameTooltip", "BagnonRequiredLevelScannerTooltip", nil, "GameTooltipTemplate")
scannerTooltip:SetOwner(WorldFrame, "ANCHOR_NONE")

-- Function to set the tooltip to the current item.
local SetTooltip = function(self)
  -- Skip non-item slots.
  if(not self:GetItem()) then return end

  -- Set the tooltip to current item.
  if (self:GetBag() == -1) then
    scannerTooltip:SetBagItem(self:GetBag(), self:GetID())

  -- Print the first tooltip line.
  print(time(), _G[scannerTooltip:GetName().."TextLeft1"]:GetText())

hooksecurefunc(Bagnon.ItemSlot, "OnEnter", SetTooltip)
  Reply With Quote