NkGenie - combobox

From Riftui Wiki

Jump to: navigation, search

This widget is used for defining a combobox widget. This is a complete custom widget individually supplied by nkGenie. You'll want to make use of layering as otherwise the combobox selection area might be overlayed by other ui elements positioned further down the screen.

If you have several combobox widgets on the UI the libary will automatically close a combobox opened for selection in case another combobox is opened.

UI.CreateFrame('nkExtCombo', 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 only supported for UI:CreateFrame(). The method :update() is not available for this widget.

Parameter Description
fontsize The fontsize used for the various text elements of the combobox. The height of the widget is automatically set to fontsize + 8.
width The width of the comboxbox
color The color used to display the combobox. See below for more information
layer The layer used for the combobox
value The initial value of the combobox. Needs to be equal to display value. See below for more information.
selection The selection of the combobox. See below for more information.
func An optional function which is called if the value of the combobox is changed. The selected value will be provided as parameter to the function.

Supported Methods


This method retrieves the underlying Rift UI element.


This method changes the selected value of the combobox. The value is equal to a text of and selection entry. If it cannot be matched to the selection the combobox value will not be changed.


This method changes the selected value of the combobox. The value is equal to a value of and selection entry. If it cannot be matched to the selection the combobox value will not be changed.


Using this method you can dynamically change the selection of an existing combobox widget. You'd want to change the value of the combobox using :setValue() or :setByValue() afterwards. If the current value of the combobox cannot be matched in the new selection this might lead to problems.

Other supported methods

Parameter Description
getValue() Returns the value of the selected entry SetVisible() Sets the visibility state of the widget (true / false)
close() Closes a combobox if open. Actually more an internal method and not neccessarily of any use.

Calling a function on selected value change

If you provide the paramter func at creation time the widget will call this function if the selected value of the widget changes. The library will call the supplied function and transfer the selected value as parameter. For example:

local myFunc = function (newValue) print (newValue) end
local combo = UI.CreateFrame('nkExtCombo', 'myCheckbox', UIParent, { func = myFunc, width = 200, fontsize = 12, color = { body = '000000', border = 'FFFFFF' }}, selection = mySelection,  
anchors = {{ from = 'CENTER', object = UIParent, to = 'CENTER' }} })

Setting the color of the combobox

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

Providing the selection

The selection is provided either at creation time using the parameter 'selection' or later using the method :updateSelection(). For both cases a LUA table has to be provided in the following format:

{ { value = , label = }, { value = , label = } }

Each element consists of the two entries: value and label. The value is what is actually stored and return by the widget (and can be used for :setByValue() ). The text entry is what is displayed to the user. This allows for using other values internally that what is displayed and helps in using different languages in your addons.

Value handling

The value handling is not perfect. I highly suggest to only use the method :setByValue(). You simply have to match the parameter of that function to the value entry of an selection element.

The method getValue() will always return the value entry of the selected selection element.

Personal tools