NkGenie - Texture

From Riftui Wiki

Jump to: navigation, search

This widget is used for displaying textures.

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


Supported parameters

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

Parameter Description
width The width of the texture widget
height The heightof the texture widget
anchors The position of the texture. See How to position widgets
callBack An optional function which is executed if the player left clicks on the texture object.

For example: callBack = function() print('hello') end

If you want to prevent 'clickthrough' on a texture you can set an empty function using this parameter: callBack = function() end

visible The visibility state of the text (true, false)
alpha The alpha level of the texture
type and path These two parameters set the actual texture file. See below.
layer Sets the layer of the texture versus parent

Supported Methods


You can change the texture using the :update() method. However sometimes the code is easier to read using the :SetTexture() method instead if you just need to change the texture. The parameters are supplied in form of a LUA table with the following format: { type = , path = }

texture:SetTexture ({ type = 'myAddon', path = 'gfx/myTexture.png' })


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

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

SetMacro (event, macro)

This method allows you to bind a Rift macro to the texture. The method takes two parameters: the event to set and the macro to execute when event fires. Supported events are:

The parameter macro is build like any ingame macro. Use '\n' to specify multi-line macros.

texture:SetMacro('LeftClick', '\s hello\n\s world')

You will have follow the secure frame model of Rift in order to be able to bind a macro to a texture. Please see the API documentation for more information on the secure frame model of Rift.

Other supported methods

Parameter Description
GetVisible() Returns the visibility of the texture (true or false)
SetVisible(flag) Sets the visibility status of a texture object. Valid parameter values are true and false
SetParent(object) Sets the parent of a texture. Use with care!
GetWidth() Returns the width of the texture (you could also use texture.width)
GetHeight() Returns the height of the texture (you could also use texture.height)
SetSecureMode(mode) Sets the secure mode of the texture. Needed for binding macros to a texture.
SetStrata(strata) Sets the strata of the texture widget
SetLayer(strata) Sets the layer of the texture widget
GetAlpha() Returns the alpha level of the texture object
SetAlpha(level) Set the alpha level of the texture object. Valid values: 0.0 to 1.0
ClearAnchors() This method clears all anchors. Needed for some anchor changes.

Specifying the texture

The texture is specified using two parameters:

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

For example:

local myTexture = UI.CreateFrame('nkExtTexture', 'myTexture', UIParent, {width = 100, height = 20, anchors = {{from = 'CENTER', to = UIParent(), to = 'CENTER'}), color = 'FFFFFF', type = 'myAddon', path = 'gfx/myTexture.png' })
Personal tools