Summary

Tooltips are notoriously difficult to handle in WoW UI code, as the interaction of GameTooltip methods can be quite complicated. The default Blizzard interface code (FrameXML) defines a GameTooltip object called GameTooltip (confusing, eh). This is used as the game's main tooltip. It consists of a number of lines(max 30); to determine how many there are, you can call the GameTooltip:NumLines() function.


Functions

SetOwner

Moves the game tooltip to a location based on the "owner" frame.

Syntax: GameTooltip:SetOwner(owner, "anchor"[, +x, +y]);

|cffee4400owner|r

Frame - Owner frame, which defines the element where the tooltip is centered on. A pointer to the frame is required, not the frame name itself (use getglobal() to get the pointer from the frame name).

|cffee4400anchor|r

String - a string that describes the anchor point as it would be set via the SetPoint() function. Anchoring methods as follows: ANCHOR_TOPRIGHT, ANCHOR_RIGHT, ANCHOR_BOTTOMRIGHT, ANCHOR_TOPLEFT, ANCHOR_LEFT, ANCHOR_BOTTOMLEFT, ANCHOR_CURSOR, ANCHOR_PRESERVE, ANCHOR_NONE.


SetText

Sets the text of the tooltip.

Syntax: GameTooltip:SetText("text" [, r, g, b, alphaValue, textWrap])

|cffee4400"text" |r

String - The text of the new tooltip. Variable can be used inplace of a string.

|cffee4400"r"|r

Optional - range 0 to 1 - red color value for text string.

|cffee4400"g"|r

Optional - range 0 to 1 - green color value for text string.

|cffee4400"b"|r

Optional - range 0 to 1 - blue color value for text string

|cffee4400"alphaValue " |r

Optional - Range - 0 to 1 specifies the transparency of the text. 0=transparent 1=Opaque, default 1.

|cffee4400"textWrap " |r

Optional - Boolean specifying whether to wrap the text string to fit the tooltip box. 1 = Wrap, 0 = Don't wrap. Default: 0.


Hide

Hides the tooltip.


Example

Move the cursor over the picture and the tooltip will appear. This is a button with a texture. The OnEnter and OnLeave events are used.