Thread Tools Display Modes
09-09-12, 05:51 PM   #1
Maggz
A Cyclonian
 
Maggz's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 45
Updating tooltip while tooltip is still active.

ok i am still a bit on the newb side, so im asking this question to see if this is something that is even possible. i can show a tiny snippet of my code to see what im tying to accomplish.

Lua Code:
  1. local malObject = {
  2.     type = "launcher",
  3.     icon = "Interface\\Addons\\MaggzAutoLog\\disabled",
  4.     label = "MaggzAutoLog",
  5.     OnClick = function(self, button)
  6.         if button == "RightButton" then
  7.             LOGSTATE()
  8.         end
  9.         if button == "LeftButton" then
  10.             if LoggingCombat() then
  11.                 disablelogging()
  12.             else
  13.                 enablelogging()
  14.             end
  15.         end
  16.     end,
  17.     OnTooltipShow = function(tooltip)
  18.     tooltip:AddLine("|cff00FF00MaggzAutoLog|r");
  19.     tooltip:AddLine("hold left mouse button to drag");
  20.     tooltip:AddLine("right click to enable/disable logging");
  21.     if LoggingCombat() then
  22.         tooltip:AddLine("Logging |cff00FF00Enabled|r");
  23.     else
  24.         tooltip:AddLine("Logging |cffFF0000Disabled|r");
  25.     end
  26. end,
  27. };

i used the minimap button creation tips i had found thru searching and atm it all works well for me, with one minor issue, i cant seem to find any documentation anywhere about how to update that last tooltip:AddLine("information here"); while the tooltip is still open and displaying. If this is something that cant be currently done that would be nice to know as well.

What my main goal is here is to add in some displayfunctionality to my addon to show current state of your combat logging. i do believe i have accomplished that with just this one issue perplexing me. Only reason i wanted to add this sort of ability is because i used loggerhead for a long while and liked how it functioned, however its not been updated for atleast last 2 patches. I know my addon is going to be NO WHERE near the functionality as that one.

If i need to post my entire LUA file here please let me know as well, i just wanted to atleast get some inut as to what im looking to do is capable
__________________
Maggz Turalyon-US

Last edited by Maggz : 09-09-12 at 06:09 PM.
  Reply With Quote
09-09-12, 08:12 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
You can call GameTooltip:AddLine() whenever you want and add text just fine. What you're missing is that you should always call GameTooltip:Show() after adding to it in order to refresh the tooltip, make sure everything is shown that you want, and to make the GameTooltip resize itself to fit your new lines.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
09-09-12, 08:38 PM   #3
Maggz
A Cyclonian
 
Maggz's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 45
i can get my tooltip to display perfectly with one exception, i would like for it to reset when i right click to update the tooltip info without having to move my mouse off the tooltip and rehover. i tried adding what your proposing and it isnt working. i tried adding just the GameTooltip:Show() in under my right onclick events and it just doesnt reset the tooltip unless i rehover over the tooltip. Am i missing something in my understanding? or can you not refresh a tooltip on a mouseclick?



++++++
sorry i passed my event in an incorrect variable i had similar to the enable and disable logging functions. it adds a line just fine, however if i just keep clicking i can end up with 500 lines of tooltips. Is there a way to simply overwrite an existing ine in your tooltip?
__________________
Maggz Turalyon-US

Last edited by Maggz : 09-09-12 at 08:49 PM.
  Reply With Quote
09-09-12, 09:09 PM   #4
Maggz
A Cyclonian
 
Maggz's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 45
AHHH i did figure it out, sorry to have bugged ya with the reply, it took me some figuring out to call a GameTooltip:ClearLines() first then append all the tooltips i want added back after that call. Tho it would be much nicer if there was a way to just remove line 3 and replace it with a new line. Sorry to seem such a newb and TY for your help, you pointed me in the right direction and i definatly appreciate that. Guess now that leaves my TODO list at figuring out how to save the position of my minimap icon properly lol thats another day tho.
__________________
Maggz Turalyon-US

Last edited by Maggz : 09-09-12 at 09:13 PM.
  Reply With Quote
09-09-12, 09:16 PM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Just change the text of line three then.

GameTooltipTextLeft3:SetText("new text!")
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
09-09-12, 10:21 PM   #6
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
Generally, if you have access to the function that creates the tooltip in the first place, you can just call it again. It shouldn't matter if the tooltip is still showing.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
09-09-12, 11:29 PM   #7
Maggz
A Cyclonian
 
Maggz's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 45
Originally Posted by Seerah View Post
Just change the text of line three then.

GameTooltipTextLeft3:SetText("new text!")
bw i will use that method over what i currently did, that is definatly alot less and cleaner method TY.
__________________
Maggz Turalyon-US
  Reply With Quote
10-15-22, 10:28 AM   #8
Ledii
A Deviate Faerie Dragon
 
Ledii's Avatar
Join Date: Apr 2013
Posts: 10
General suggestions for handling tooltips

If you want your addon to work together with other addons which also modifies the tooltips,
you might need to be a little more sophisticated around how you modify your lines.
You will not always know which lines are yours. And clearing the entire tooltip will end up clearing more than you want too...

Here is the approach I ended up using:

Code:
local cachedUnit = nil

function OnTooltipSetUnit()
	--Figure out if we are reading data from mouseover or target
	local unit = "mouseover"
	if (not UnitExists(unit)) then
		unit = "target"
	end

	--Cache unit so that we can run it again later with the same unit
	cachedUnit = unit
	AppendCustomTooltipLines()
end

function AppendCustomTooltipLines()
	--Add custom lines here with custom color
	local r = 1
	local g = 1
	local b = 1
	GameTooltip:AddLine("Custom text here...", r, g, b)
end

function UpdateTooltip()
	if cachedUnit == nil then return end

	--Makes sure custom tooltip lines are cleared
	GameTooltip:SetUnit(cachedUnit)
end

GameTooltip:HookScript("OnTooltipSetUnit", OnTooltipSetUnit)
You may then call UpdateTooltip() wherever, when you know there is new data to apply.
__________________
Take it as it comes...
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Updating tooltip while tooltip is still active.


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