WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Legion Beta archived threads (https://www.wowinterface.com/forums/forumdisplay.php?f=177)
-   -   GameTooltip has no point set when shown (https://www.wowinterface.com/forums/showthread.php?t=53963)

Seerah 07-20-16 09:12 PM

GameTooltip has no point set when shown
 
A user reported some odd behavior with my addon TipTop. TipTop adds a background frame to the tooltip in addition to other features. The TipTop bg is set to have the GameTooltip as its parent. This user has the tooltip set to display at his mouse in the TipTop options.

He reported that when mousing over units and objects in the world, the background of the tooltip was appearing at its last seen location before jumping to the tooltip's new cursor position.

In my code, I have an "OnShow" script for the TipTop background. Since the TipTop bg is parented to the GameTooltip, whenever the tooltip shows, the bg shows and this function is called. In my OnShow function I added a print call:
Lua Code:
  1. GameTooltip:GetPoint()
It prints out nil every time.

The location of the GameTooltip is not being set until after it is being told to show. It does exist by the time the tooltip information (lines and statusbar) is displayed.

I poked around a bit more and can replicate this with the default UI as well. All it requires is this code:
Lua Code:
  1. hooksecurefunc("GameTooltip_SetDefaultAnchor", function (tooltip, parent)
  2.      GameTooltip:SetOwner(parent, "ANCHOR_CURSOR")
  3.      print(GameTooltip:GetPoint() or "nil")
  4. end)
Mouse over 2 things far enough apart and watch the background jump from location to location.

runamonk 10-26-16 12:37 PM

What about referencing the passed in tooltip instead of GameToolTip. This is how I am doing it and I've not noticed any weird tooltip behavior.

Lua Code:
  1. hooksecurefunc("GameTooltip_SetDefaultAnchor", function(tooltip, parent)
  2.     local f = GetMouseFocus();
  3.     if f == WorldFrame or type(f) == "table" then
  4.         tooltip:SetOwner(parent, "ANCHOR_CURSOR");
  5.     else
  6.         tooltip:ClearAllPoints();
  7.         tooltip:SetOwner(parent, "ANCHOR_NONE");
  8.         tooltip:SetPoint("BOTTOM",f,"TOP",0,5);
  9.     end
  10. end)

Quote:

Originally Posted by Seerah (Post 316666)
A user reported some odd behavior with my addon TipTop. TipTop adds a background frame to the tooltip in addition to other features. The TipTop bg is set to have the GameTooltip as its parent. This user has the tooltip set to display at his mouse in the TipTop options.

He reported that when mousing over units and objects in the world, the background of the tooltip was appearing at its last seen location before jumping to the tooltip's new cursor position.

In my code, I have an "OnShow" script for the TipTop background. Since the TipTop bg is parented to the GameTooltip, whenever the tooltip shows, the bg shows and this function is called. In my OnShow function I added a print call:
Lua Code:
  1. GameTooltip:GetPoint()
It prints out nil every time.

The location of the GameTooltip is not being set until after it is being told to show. It does exist by the time the tooltip information (lines and statusbar) is displayed.

I poked around a bit more and can replicate this with the default UI as well. All it requires is this code:
Lua Code:
  1. hooksecurefunc("GameTooltip_SetDefaultAnchor", function (tooltip, parent)
  2.      GameTooltip:SetOwner(parent, "ANCHOR_CURSOR")
  3.      print(GameTooltip:GetPoint() or "nil")
  4. end)
Mouse over 2 things far enough apart and watch the background jump from location to location.



All times are GMT -6. The time now is 05:47 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI