View Single Post
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.