Thread Tools Display Modes
01-28-22, 05:23 PM   #1
ranjeet
A Defias Bandit
Join Date: Jan 2022
Posts: 2
Getting Tooltip Text

I found a macro that will enumerate through whatever tooltip is showing but cannot get it to work when trying to run it straight from a LUA file.

The macro is:
/run for i=1,GameTooltip:NumLines()do local mytext=_G["GameTooltipTextLeft"..i] local text=mytext:GetText()print(text)end

It works perfectly when hovering over something in-game and running the macro via key binding. But in order to get it to work in the main LUA file for this addon, it needs to run when a tooltip is actually there and ready to read. I am able to execute it via:

GameTooltip:HookScript("OnTooltipSetDefaultAnchor", somefunction)

This was the only GameTooltip handler that would fire for tooltips that are not associated with an item or unit. I need it to fire when highlighting over a chest, which cannot be done with any of the other GameTooltip handlers.

Does anyone have any idea on how I can get this macro code to work? I tried putting it in somefunction without the '/run' but nothing happens. I would greatly appreciate the help.
  Reply With Quote
01-29-22, 10:20 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
This might be better until someone who knows more about it chips in:

Lua Code:
  1. GameTooltip:HookScript("OnShow", function(self)
  2.     print("|cff00ff00------")
  3.     for i=1, self:NumLines() do
  4.         print(_G["GameTooltipTextLeft"..i]:GetText())
  5.     end
  6. end)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
01-31-22, 11:03 AM   #3
ranjeet
A Defias Bandit
Join Date: Jan 2022
Posts: 2
Thank you so much, this worked exactly how I wanted it to!
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Getting Tooltip Text

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