NkGenie - Menu

From Riftui Wiki

Jump to: navigation, search

The nkExtMenu widget is one of the more complex widget which nkGenie can create. Still it's use is fairly simple and very usefull. Basically it can create a menu which can be bound to any object on the screen and dynamically be displayed. The whole functionality of the (nk) Button is done using this widget.

The height of the menu is automatically calculated based on the menu entries. You can change the menu entries after widget creation through the :update() method if needed.

The menu is automatically put into secure mode in order to be able to use macros. This means you have to make sure that it's parent tree is also in secure mode.

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

Contents

Supported parameters

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

Parameter Description
width The width of the menu
fontsize The fontsize used for the menu labels
items The menu items. See below
color The color definition. See below
anchors The position of the menu widget. See How to position widgets
layer The layer of the button versus parent

Supported Methods

getElement()

This method retrieves the underlying Rift UI element.

Other supported methods

Method Description
getEntryCount() Returns the number of menu entries
GetVisible() Retrieve the visibility status of a frame object. Returns true or false
SetVisible(flag) Sets the visibility status of the menu object. Valid parameter values are true and false
getItems() Returns the menu item definition. This is actually the same as accessing the property nkExtMenu.menuItems

Menu colorization

The color of the menu and it's entries is done using the color property. You'll have to supply a LUA table using the following format:

color = { body = 'hex code', bodyactive = 'hex code', border = 'hex code', labelactive = 'hex code', labelinactive = 'hex code' }

Parameter Description
body Main color of the menu master frame
border Border color of the menu master frame
bodyactive This is the color used to highlight a menu item frame if it's moused over
labelactive This is the color used to highlight a mneu item label if it's moused over
labelinactive This is the standard color for menu item labels

Menu item definition

The actual menu entries are supplied using the 'items' parameters. You can change the menu items after widget creation using the :update() method. The menu items are supplied in form of a LUA table using elements of the following format:

{ closeOnClick = boolean, func = function () end, macro = 'macro text', label = 'label text' }

Parameter Description
label The label of the menu entry
func The function to be called if the menu entry is clicked. This is not optional, supply func = function() end if not needed.
macro Optionally you can specify a macro to execute if the menu entry is clicked
closeOnClick Specifies if the menu is automatically to be hidden if an entry is clicked (true / false)

In addition the menu widget supports menu entry definition of the following format:

{ seperator = true }

This entry will create a seperator line between two menu entries.

This is an example of a valid menu item definition table:

local entries = { 
   { label = 'entry 1', func = function () print ('entry 1 clicked') end, closeOnClick = true },
   { seperator = true },
   { label = 'entry 2', func = function () end, macro = '/s entry 2 clicked', closeOnClick = true }
}
Personal tools
Namespaces
Variants
Actions
Menu
Wiki
Toolbox