Class
caplin.menu.model

Menu

Extends .
The caplin.menu.model.Menu is the model representation of a menu. This class presents a simple API you can use in order to access/modify the internal state of the model.

In order to listen to item events, you can either listen for the event 'action' on the actual item or, if a child caplin.menu.Model has 'eventName' inside its options, listen to that value.

The table below explains each possible option.

namedefaulttypedescription
labelString The item label.
classifierString Allows you to set a classifier to your menu to differentiate it from other menus
typemenuString The menu type.

Constructor Summary

Attributes Name and Description
caplin.menu.model.Menu(Map options)

Method Summary

Attributes Name and Description
void append(Variant item)

Allows you to append either a single item or an array of items to the menu.

Object get(Number index)

Returns the item in the given position.

Array getAll()

Returns a copy of the list of all menu items in this menu.

void insert(Number index, Object item)

Inserts an item in the given position.

void remove(Number index)

Removes an item from the specified index.

void removeAll()

Removes all the items inside the menu.

Constructor Detail

caplin.menu.model.Menu(Map options)

Parameters
Map options A map of options.

Method Detail

void append(Variant item)

Allows you to append either a single item or an array of items to the menu. This item(s) must implement the caplin.menu.model.Item class.

Parameters
Variant item The array of items or the single item that needs to be appended.
Throws
caplin.core.Error
If item is not a instance of caplin.menu.model.Item.

Object get(Number index)

Returns the item in the given position.

Parameters
Number index The item index.
Throws
caplin.core.Error
If index is outside of the bounds of the current menu list.
Returns
{Object}

Array getAll()

Returns a copy of the list of all menu items in this menu.

Returns
{Array} An array of menu items contained in this menu.

void insert(Number index, Object item)

Inserts an item in the given position.

Parameters
Number index The index in which the item will be inserted.
Object item The item to be inserted.
Throws
caplin.core.Error
If item is not a instance of caplin.menu.model.Item.
caplin.core.Error
If index is outside of the bounds of the current menu list.

void remove(Number index)

Removes an item from the specified index.

Parameters
Number index The index from which the item will be removed.
Throws
caplin.core.Error
If index is outside of the bounds of the current menu list.

void removeAll()

Removes all the items inside the menu.