Caplin Trader 5.1.0

Class: module:ct-menu/model/Menu

module:ct-menu/model/Menu(options)

new module:ct-menu/model/Menu(options)

The 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 module:ct-menu/Model has 'eventName' inside its options, listen to that value.

Extends:
Parameters:
Name Type Description
options Map

A map of options.

Properties
Name Type Description
label String

The item label.

classifier String

Allows you to set a classifier to your menu to differentiate it from other menus

type String

The menu type.

Extends

Methods

append(item)

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

Parameters:
Name Type Description
item Variant

The array of items or the single item that needs to be appended.

Throws:

If item is not a instance of module:ct-menu/model/Item.

Type
module:ct-core/Error

disable()

Disables the item.

Inherited From:

enable()

Enables the item.

Inherited From:

get(index) → {Object}

Returns the item in the given position.

Parameters:
Name Type Description
index Number

The item index.

Throws:

If index is outside of the bounds of the current menu list.

Type
module:ct-core/Error
Returns:
Type
Object

getAll() → {Array}

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

Returns:

An array of menu items contained in this menu.

Type
Array

getByClassifier(classifier, allowPartialMatch) → {Array}

Returns a list of items with the given classifier.

Parameters:
Name Type Description
classifier String

The classifier to search for.

allowPartialMatch Boolean

Allows partial matches for the search.

Returns:

A list of {module:ct-menu/model/Item} objects with the given classifier, or an empty array if none are found.

Type
Array

getByLabel(label, allowPartialMatch) → {Array}

Returns a list of items with the given label.

Parameters:
Name Type Description
label String

The label to search for.

allowPartialMatch Boolean

Allows partial matches for the search.

Returns:

A list of {module:ct-menu/model/Item} objects with the given label, or an empty array if none are found.

Type
Array

getClassifier() → {String}

Returns the item's classifier.

Inherited From:
Returns:
Type
String

getLabel() → {String}

Returns the item's label.

Inherited From:
Returns:
Type
String

insert(index, item)

Inserts an item in the given position.

Parameters:
Name Type Description
index Number

The index in which the item will be inserted.

item Object

The item to be inserted.

Throws:

remove(index)

Removes an item from the specified index.

Parameters:
Name Type Description
index Number

The index from which the item will be removed.

Throws:

If index is outside of the bounds of the current menu list.

Type
module:ct-core/Error

removeAll()

Removes all the items inside the menu.