-
Posted by Amemir on Mon, 13 Sep 2010 16:02:11
Is it possible to scan a tooltip of an item in the bank? I've tried the following code (modified from the example in the snippet)
f = CreateFrame('GameTooltip', 'MyTooltip', UIParent, 'GameTooltipTemplate') f:SetOwner(UIParent, 'ANCHOR_NONE') f:SetBagItem(0,1) print (MyTooltipTextLeft2:GetText()) f:Hide()
while it works perfectly for an item that is in my bags when I change
f:SetBagItem(0,1)
to
f:SetBagItem(-1,1)
it always returns nil.
-
Posted by jnwhiteh on Mon, 13 Sep 2010 16:11:04
It might be that the tooltip takes time to load, it might be worth making the tooltip visible and seeing it if works normally before you try getting the text from it.
-
Posted by Amemir on Mon, 13 Sep 2010 17:10:54
It might be that the tooltip takes time to load, it might be worth making the tooltip visible and seeing it if works normally before you try getting the text from it.
Would I do that by using
f:Show()
(tried it but nothing seemed to change) or some other way? -
Posted by jnwhiteh on Mon, 13 Sep 2010 17:15:01
When you do f:Show and then set it with a bag item, does it display the bag item's info? Also, you can always dig into the FrameXML for the bank and see how it's doin git.
-
Posted by Amemir on Mon, 13 Sep 2010 17:36:47
With f = CreateFrame('GameTooltip', 'MyTooltip', UIParent, 'GameTooltipTemplate')
f:Show() f:SetOwner(UIParent, 'TOPLEFT') f:SetBagItem(0, 1)
I get a blank frame the size of the items tooltip in the upper left corner of the screen, however when I set it to
f:SetBagItem(-1, 0)
however not even the frame displays. -
Posted by jnwhiteh on Mon, 13 Sep 2010 17:39:54
Then I'd look at how the bank frame code in the FrameXML accomplishes this.
-
Posted by Amemir on Mon, 13 Sep 2010 17:54:40
Checking BankFrame all I can find seems to be
function BankFrameItemButton_OnEnter (self) GameTooltip:SetOwner(self, "ANCHOR_RIGHT"); if ( not GameTooltip:SetInventoryItem("player", self:GetInventorySlot()) ) then if ( self.isBag ) then GameTooltip:SetText(self.tooltipText); end end CursorUpdate(self); end
which leads me to believe that bank items need to be moused over for their tooltips to show, if I'm not mistaken?
Edit: Also I'd like to say thanks for the quick replies, I've been trying to get this to work most of the day and I wasn't getting anywhere with it.
-
Posted by jnwhiteh on Mon, 13 Sep 2010 18:03:39
The code uses SetInventoryItem.
GameTooltip:SetInventoryItem("player", 67) is the top-right slot in the bank.
-
Posted by Amemir on Mon, 13 Sep 2010 19:16:36
Thanks for the help =D after playing around with it a bit more I finally have a working version. Final product below
function AM_SendableItem(bag, slot) local f = CreateFrame('GameTooltip', 'AM_ItemCheck', UIParent, 'GameTooltipTemplate') f:SetOwner(UIParent, 'ANCHOR_NONE') if AM_AtMail then f:SetBagItem(bag,slot) elseif AM_AtBank then f:SetInventoryItem("player", slot) end if AM_ItemCheckTextLeft2:GetText() == "Soulbound" then AM_IsSendable = false else AM_IsSendable = true end f:Hide() end
-
Posted by jnwhiteh on Mon, 13 Sep 2010 19:36:56
Feel free to make it into a snippet that someone else might find useful in their own addons!