NkGenie - ScrollBox

From Riftui Wiki

Jump to: navigation, search

In essence the nkExtScrollbox is nothing else but a vertical slider. This is a complete custom widget individually supplied by nkGenie. It's use is whenever you need to build an area on the screen which is bigger than the available space. Then you can use this widget to create a scrollbar and hook it's events to custom functions handling the scrolling of your content frame.

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

Contents

Supported parameters

Due to the nature of the scrollbox widget you cannot change it as dynamically as other widgets after creation. The following parameters are only supported for UI:CreateFrame(). The method :update() does not allow to change the widget after creation.

Parameter Description
height The height of the widget.
range The range of the values of the scrollbox. Has to be provided in form of a LUA table with two values: { from, to }
color The color definition for the widget. See below.
layer The layer of the widget versus parent
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 scrollbox changes. See below.

Supported Methods

getElement()

This method retrieves the underlying Rift UI element.

SetValue(flag)

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

The value change function will not be called.

updateRange(range)

It's possible to update the range after creation using this method. The method requires a LUA table of format { from, to } as parameter. The slider value will be automatically reset to 1.

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 (scrollbox) 
 print (scrollbox.value)
end
 
local scrollbox= UI.CreateFrame('nkExtScrollBox', 'myScrollBox', UIParent, { func = myFunc, value = 1, range = {1, 5}, height = 100, color = { body = '000000', border = 'FFFFFF' }}, 
anchors = {{ from = 'CENTER', object = UI.Parent, to = 'CENTER' }} })

Setting the color of the scrollbox

You will have to supply a color LUA table with two parameters 'body' and 'border'. For example: color = { body = '0000000', border = 'FFFFFF' }.

Personal tools
Namespaces
Variants
Actions
Menu
Wiki
Toolbox