Getting started

Embedding LibQTip into your addon

LibQTip uses LibStub, and is designed to be embedded directly within your AddOn.

Using the WoWAce .pkgmeta feature

If your AddOn is hosted on WoWAce, you can use the .pkgmeta externals feature to have the packager embed LibQTip for you. This .pkgmeta example automatically embeds the latest tagged version of LibStub and LibQTip-1.0:

     url: svn://
     tag: latest
     url: svn://
     tag: latest

Then add references to them in the .toc file:


Minimalist hard-embedding

Download the latest beta or release package and copy LibStub.lua and LibQTip-1.0.lua into your addon folder. Then references them in the .toc file:


Simple Use

Provided you have an existing anchor frame in your FooBarAddon, here is how to add a simple tooltip:

 -- Get a reference to the lib
 local LibQTip = LibStub('LibQTip-1.0')
 local function anchor_OnEnter(self)
   -- Acquire a tooltip with 3 columns, respectively aligned to left, center and right
   local tooltip = LibQTip:Acquire("FooBarTooltip", 3, "LEFT", "CENTER", "RIGHT")
   self.tooltip = tooltip 
   -- Add an header filling only the first two columns
   tooltip:AddHeader('Anchor', 'Tooltip')
   -- Add an new line, using all columns
   tooltip:AddLine('Hello', 'World', '!')
   -- Use smart anchoring code to anchor the tooltip to our frame
   -- Show it, et voilà !
 local function anchor_OnLeave(self)
   -- Release the tooltip
   self.tooltip = nil
 -- Somewhere in the anchor initialization
 anchor:SetScript('OnEnter', anchor_OnEnter)
 anchor:SetScript('OnLeave', anchor_OnLeave)

Please note that releasing a tooltip is not intended to be optional. Doing so has very little overhead versus clearing it and hiding it, and allows an overall reduction in frame usage. If your code does not release the tooltip, it locks its frames and forces LibQTip to create more frames for other tooltips.

Changing fonts

The fonts can be changed using the :SetFont and :SetHeaderFont methods of the tooltip. This will not change existing text, so it should be done before adding anything to the tooltip. As the fonts are reset each time the tooltip is acquired, these methods must be called each time.

 -- New font looking like GameTooltipText but red with height 15
 local red15Font = CreateFont("FooBarRed15Font")
 red15Font:SetFont(GameTooltipText:GetFont(), 15)
 -- New font looking like red15font but with height 17
 local red17Font = CreateFont("FooBarRed17Font")
 red17Font:SetFont(red17Font:GetFont(), 17) 
 local function anchor_OnEnter(self)
   -- Acquire a tooltip
   local tooltip = LibQTip:Acquire("FooBarTooltip", 3, "LEFT", "CENTER", "RIGHT")
   -- Set the fonts
   -- ...

To be continued.


Posts Quoted:
Clear All Quotes