Thread Tools Display Modes
12-11-21, 03:06 PM   #1
Platine
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Dec 2010
Posts: 72
CreateFrame - frameType: GameTooltip

What's wrong with the code below?

CreateFrame("GameTooltip", "ST_Tooltip", UIParent, "GameTooltipTemplate");
ST_Tooltip:ClearAllPoints();
ST_Tooltip:SetPoint("CENTER", UIParent, "CENTER", 0, 0);
ST_Tooltip:ClearLines();
ST_Tooltip:AddLine("My frame", 1, 1, 1);
ST_Tooltip:AddLine("Second line", 1, 1, 1);
ST_Tooltip:Show();

I cannot see my frame on the screen.
  Reply With Quote
12-11-21, 03:31 PM   #2
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
Tooltips require an owner frame. You need to use ST_Tooltip:SetOwner().

Useful pages:

https://wowpedia.fandom.com/wiki/UIOBJECT_GameTooltip
https://wowpedia.fandom.com/wiki/API...oltip_SetOwner
  Reply With Quote
12-11-21, 03:40 PM   #3
Platine
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Dec 2010
Posts: 72
ST_Toolpit:SetOwner(WorldFrame, "ANCHOR_NONE");

Now it works. thanks.
  Reply With Quote
12-11-21, 03:41 PM   #4
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Lua Code:
  1. local tt = CreateFrame("GameTooltip", "ST_Tooltip", UIParent, "GameTooltipTemplate")
  2. tt:SetOwner(UIParent, "ANCHOR_TOP", 0, -400)
  3. tt:AddLine("My frame")
  4. tt:AddLine("Second line")
  5. tt:Show()
  Reply With Quote
12-12-21, 07:38 AM   #5
Platine
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Dec 2010
Posts: 72
Thumbs down

OK, thanks everybody, addon works correctly.

Lua Code:
  1. ST_Tooltip=CreateFrame("GameTooltip", "ST_Tooltip", UIParent, "GameTooltipTemplate");
  2. ST_Tooltip:SetOwner(UIParent, "ANCHOR_CURSOR");
  3.  
  4. GameTooltip:HookScript("OnTooltipSetItem", function(self)
  5.   ST_Tooltip:ClearLines();
  6.   ST_Tooltip:AddLine("My frame", 1, 1, 1);
  7.   ST_Tooltip:AddLine("Second line", 1, 1, 1);
  8.   ST_Tooltip:Show();
  9. );

Last edited by Platine : 12-12-21 at 10:33 AM.
  Reply With Quote
12-12-21, 10:34 AM   #6
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,359
https://wowpedia.fandom.com/wiki/API...ooltip_AddLine
  Reply With Quote
12-12-21, 11:06 AM   #7
Platine
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Dec 2010
Posts: 72
Thank you all.

Last edited by Platine : 12-17-21 at 04:21 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » CreateFrame - frameType: GameTooltip

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