Thread Tools Display Modes
07-20-16, 09:12 PM   #1
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
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.
__________________
"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


Last edited by Seerah : 07-20-16 at 09:14 PM. Reason: added print statement
 
10-26-16, 12:37 PM   #2
runamonk
A Theradrim Guardian
 
runamonk's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 61
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)

Originally Posted by Seerah View Post
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.
 
 

WoWInterface » Site Forums » Archived Beta Forums » Legion Beta archived threads » GameTooltip has no point set when shown

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