NkGenie - Text

From Riftui Wiki

Jump to: navigation, search

This widget is used for displaying text.

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

Contents

Supported parameters

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

Parameter Description
fontsize The font size to use
text The text to display
height The height of the text widget
width The width of the text widget
color The color of the text in format: color=hex code
anchors The position of the text. See How to position widgets
font and path The font file to use. See below
visible The visibility state of the text (true, false)
wordwrap Specifies wether text should be word wrapped (true / false)
layer The layer of the text versus parent
template The template to use when building the frame. See Using templates to reduce number of parameters

Supported Methods

getElement()

This method retrieves the underlying Rift UI element.

SetEvent(event, function)

You can supply a LeftClick function at creation time using the callBack parameter. However if you want to set any other event (or be consistent when setting events) you can use the SetEvent method. The method takes two parameters: the event to set and the function to execute when event fires. Supported events are:

The parameter function is provided as follows: function () ... end

text:SetEvent('LeftClick', function() print ('hello') end)

ClearWidth()

Clearing the width of a text object is a bit tricky. Using the update mthod text:update({ width = nil }) will not work in this special case. Use this method if you need to clear the width of a text object.

GetWidth()

If you have set the width of a text widget at creation time or using the update() method you can access the width of the textdirectly using widget.width. This will not work for text which's width is dynamically done using the two anchors. If you'd need to know the width of these types of text you'd want to use :GetWidth().

GetHeight()

If you have set the height of a text widget at creation time or using the update() method you can access the height of the text directly using widget.height. This will not work for text which's height is dynamically done using the two anchors. If you'd need to know the height of these types of text you'd want to use :GetHeight().

Other supported methods

Parameter Description
getText() Returns the text of the widget
SetVisible(flag) Sets the visibility status of a text object. Valid parameter values are true and false
SetLayer(layer) Sets the layer of the frame versus it's parent.

Using custom fonts

You can use custom fonts to display a text object. If you want to do this you need to include the font definition file within your addon and supply to parameters at creation or update time:

Parameter Description
path This is equal to your addon's name as specified in the RiftAddon.toc file
font The path to the font file to use

For example:

local myText = UI.CreateFrame('nkExtText', 'myText', UIParent, {text = 'hello word', fontsize=12, anchors = {{from = 'CENTER', to = UIParent(), to = 'CENTER'}), color = 'FFFFFF', path = 'myAddon', font = 'fonts/myFont.ttf' })
Personal tools
Namespaces
Variants
Actions
Menu
Wiki
Toolbox