WowAce.com
Home
Addons
Authors
Forums
Knowledge base
Paste
Site issues
Sign in
LibQTip-1.0
Overview
Files
Tickets
Pages
Repositories
Subscriptions
Curse
Getting started
r14
Source
Markup:
*
==__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: ---- <<code text>> externals: libs/LibStub: url: svn://svn.wowace.com/wow/libstub/mainline/trunk tag: latest libs/LibQTip-1.0: url: svn://svn.wowace.com/wow/libqtip-1-0/mainline/trunk tag: latest <</code>> ---- Then add references to them in the .toc file: <<code text>> libs\LibStub\LibStub.lua libs\LibQTip-1.0\LibQTip-1.0.lua <</code>> ===__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: <<code text>> LibStub.lua LibQTip-1.0.lua <</code>> ==__Simple Use__== Provided you have an existing anchor frame in your FooBarAddon, here is how to add a simple tooltip: <<code>> -- 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 tooltip:SmartAnchorTo(self) -- Show it, et voilĂ ! tooltip:Show() end local function anchor_OnLeave(self) -- Release the tooltip LibQTip:Release(self.tooltip) self.tooltip = nil end -- Somewhere in the anchor initialization anchor:SetScript('OnEnter', anchor_OnEnter) anchor:SetScript('OnLeave', anchor_OnLeave) <</code>> **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. <<code>> -- New font looking like GameTooltipText but red with height 15 local red15Font = CreateFont("FooBarRed15Font") red15Font:SetFont(GameTooltipText:GetFont(), 15) red15Font:SetTextColor(1,0,0) -- New font looking like red15font but with height 17 local red17Font = CreateFont("FooBarRed17Font") red17Font:CopyFontObject(red15Font) 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 tooltip:SetFont(red15font) tooltip:SetHeaderFont(red17font) -- ... <</code>> To be continued.
Markup Type:
*
The type of markup for this entry.
Click here for details
.
WikiCreole
BBCode
Safe HTML
Plain Text
Markdown
Textile
Curse Wiki (Deprecated)