NkGenie - Slider

From Riftui Wiki

Jump to: navigation, search

This widget creates a slider ui element. This is a complete custom widget individually supplied by nkGenie. The standard UI creates a similar widget but the nkGenie variant has some additional functionality. Actually this widget was created back when the standard UI slider was in a near useless state.

In addition to the slider itself it will automatically create and place a label in front or behind the slider. You cannot specifiy a slider widget without label, you can however set the width of the label to 0.

This widget has one deficit in it's current version: It requires the library nkTools without explicitely defining this. A change will be made soon to no longer have the dependency toward nkTools.

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


Supported parameters

Due to the nature of the slider widget you cannot change it as dynamically as other widgets after creation. The following parameters are supported for UI:CreateFrame(). The method :update() only supports the parameter 'text'.

Parameter Description
width The width of the slider element
range The range of the values of the slider. Has to be provided in form of a LUA table with two values: { from, to }
precision This is an optional parameter telling the slider to use decimal points for the value (and range). A precision of 1 means x.x, 2 means x.xx etc. Values are rounded to the specified precision. If none is provided the value will be rounded to the next integer value.
labelwidth The width of the label of the slider.
fontsize The fontsize used for the label of the checkbox
labelinfront Defines if the label is shown in front or behind the slider element (true = front, false = behind)
text Text text of the label
color Specifies the color of the widget. See below.
anchors The position of the mask widget. See How to position widgets
func An optional function which is automatically called if the value of the slider changes. See below.

Supported Methods


This method retrieves the underlying Rift UI element.


This method changes the value of the slider and positiones the slider box. The new value has to be within range of the slider. If it's not the slider box will not be positioned correctly and might act strange.

The value change function will not be called.

Other supported methods

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

Calling a function on value change

If you provide the paramter func at creation time the widget will call this function if the value of the widget changes. The library will call the supplied function and transfer the widget itself as parameter. You can then retrieve the value by using the proporty 'value' on the widget. For example:

local myFunc = function (slider) 
 print (slider.value)
local slider = UI.CreateFrame('nkExtSlider', 'mySlider', UIParent, { func = myFunc, value = 5, range = {1, 5}, labelwidth = 75, fontsize = 12, labelinfront = true, text = 'my slider:', color = { body = '000000', border = 'FFFFFF' }}, 
anchors = {{ from = 'CENTER', object = UI.Parent, to = 'CENTER' }} })

Setting the color of the slider

You will have to supply a color LUA table with two parameters 'body' and 'border'. For example: color = { body = '0000000', border = 'FFFFFF' }. The border color will also be used for the label of the slider.

Personal tools