NkGenie - ItemToolTip

From Riftui Wiki

Jump to: navigation, search

The width name nkExtItemTooltip might be slighty misleading. While it started as a widgt for showing item tooltips through time it's usage has broadened. You can use it to display any type of tooltip. It creates a bordered frame with the following layout:

<title> <bop> <subTitle> <subValue>


<lines> <onUseText> <onEquipText> <descText> <flavText>


<addInfoLines>

Depending on the parameters individual lines will automatically be hidden. If no <addInfoLines> are supplied the second separator line will be hidden.

The tooltip width and height will be automatically calculated based on the values supplied and / or the definition of the tooltip text lines.

UI.CreateFrame('nkExtItemTooltip ', name, parent, {})

Contents

Supported parameters

The following parameters are supported for UI:CreateFrame() and frame:update()

Parameter Description
title The text to display in the title line of the tooltip
titleColor This setting defines the color of the first line of the tooltip. It's provided in form of a hex color code. If this parameter is omitted the tooltip will try to color the title line based on the parameter quality. If neither is supplied the title line will be colored white.
quality Usefull in case of an item being display with the tooltip. this will color the title text based on quality: ommit = white, 1 = green, 2 = blue, 3 = epic
bop In case of an item being displayed this optional parameter will display the message 'Bind on pickup' if set to true
account In case of an item being displayed this optional parameter will display the message 'Account bound' if set to true
bound In case of an item being displayed this optional parameter will display the message 'Soldbound' if set to true
subTitle A text which is displayed below <title> and <bop> line
subValue A text which is displayed to the right of <subTitle>
lines The actual content of the tooltip. See below for more information.
onUseText In case of an item being displayed this optional parameter will display an 'onUse' text with appropiate coloring
onEquipText In case of an item being displayed this optional parameter will display an 'onEquip' text with appropiate coloring
descText In case of an item being displayed this optional parameter will display an 'description' text with appropiate coloring
flavText In case of an item being displayed this optional parameter will display an 'flavor' text with appropiate coloring
addInfoLines Additional lines of content of the tooltip. See below for more information.
anchors The position of the tooltip widget. See How to position widgets. Actually this parameter is optional. See below.
alignTo An optional parameter if anchors is not provided. See below.
x An horizontal offset of pixel if the parameter alignTo is used. See below.
y An vertical offset of pixel if the parameter alignTo is used. See below.

Supported Methods

getElement()

This method retrieves the underlying Rift UI element.

Other supported methods

Parameter Description
SetVisible() Sets the visibility state of the widget (true / false)

Line definition

While the rest of the parameters are somewhat fixed the number of lines is variable. This parameter is supplied in form of a LUA table with the following element format:

{ text = 'text', width = int, height = int, fontsize = int, color = 'hex code' }

Due to the fact that a lot of parameters are option, a simple tooltip can be created as easy as this:

local myTooltip = UI.CreateFrame('nkExtItemTooltip', 'myTooltip', UIParent, { title = 'my tooltip', lines = { text = 'line 1', width = 100, height = 12, fontsize = 10, color = 'FFFFFF' }, 
{ text = 'line 2', width = 100, height = 12, fontsize = 10, color = 'FFFFFF' }} })

Using the same format you can add further tooltip lines to the bottom of the tooltip using the parameter addInfoLines. This parameter requires a LUA table with the exact same format as lines. A separator line will be automatically displayed above the lines defined by the parameter addInfoLines.

Anchoring the tooltip

The tooltip can be positioned on the screen using three different methods:

(1) Using the anchors parameter

This works exactely the same as any other anchors. Simply define the anchor and the tooltip will be displayed exactely there.

(2) alignTo parameter

If you supply the alignTo the tooltip will be dynamically anchored to the object. The alignTo parameter is required to be an UI elmenet which is used to build a dynamic anchors object. You can define an offset using the option parameters x and y.

(3) If neither the anchors nor the alignTo parameter are supplied the tooltip will be bound to the current mouse position. It will not move with the move - the mouse coordinates are simply calculated when displaying the tooltip. This method also accepts the parameters x and y to be supplied to define an offset.

Personal tools
Namespaces
Variants
Actions
Menu
Wiki
Toolbox