NkGenie - Radio Button

From Riftui Wiki

Jump to: navigation, search

This widget is used for defining a radio button element. This is a complete custom widget individually supplied by nkGenie. It will create the radio button ui element and place a label in front. It is not possible to create a radio button without label. You could set the label width to 0 though.

Actually the RadioButton widget is nothing but a combination of several nkExtCheckbox widgets allowing for only one of the checkboxes of the group being selected at one time.

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


Supported parameters

Due to the nature of the checkbox widget you cannot change it as dynamically as other widgets after creation. The following parameters are supported for UI:CreateFrame(). The method :update() cannot be used to update the widget.

Parameter Description
labelwidth The width of the label of the checkbox. The total width of the widgt is: labelwidth + fontsize + 7
fontsize The fontsize used for the label of the checkbox
label Text text of the label
value The initial value of the radio button. Has to be included in options table
options The options of the radio button element in form of a simply Lua table: { 'value 1', 'value 2', 'value 3' }
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 selection state of the widget changes. See below.

Supported Methods


This method retrieves the underlying Rift UI element.

Calling a function on state change

If you provide the parameter func at creation time the widget will call this function if the checked state of the widget changes (e.g. user clicks one of the widget's checkboxes). The library will call the supplied function and transfer the value (text) of the individual checkbox which was clicked by the user as parameter. For example:

local myFunc = function (value) 
 print (value)
local radiobutton = UI.CreateFrame('nkExtRadioButton', 'myRadioButton', UIParent, { func = myFunc, value = 'text1', labelwidth = 75, fontsize = 12, text = 'my radiobutton:', options = {'text1', 'text2', 'text3'},
color = { body = '000000', border = 'FFFFFF' }}, anchors = {{ from = 'CENTER', object = UIParent, to = 'CENTER' }} })

Setting the color of the radio button

You will have to supply a color Lua table with at least the two parameters 'body' and 'border'. For example: color = { body = '0000000', border = 'FFFFFF' }. The border color will also be used for the box indicating the checked state of the widget.

The label of the radio button will automatically use the border color.

Personal tools