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.
name | default | 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 | menu | String | The menu type. |
Attributes | Name and Description |
---|---|
|
caplin.menu.model.Menu(Map options)
|
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. |
►
caplin.menu.model.Menu(Map options)
Map | options | A map of options. |
►
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.
Variant | item | The array of items or the single item that needs to be appended. |
►
Object
get(Number index)
Returns the item in the given position.
Number | index | The item index. |
►
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.
Number | index | The index in which the item will be inserted. |
Object | item | The item to be inserted. |
►
void
remove(Number index)
Removes an item from the specified index.
Number | index | The index from which the item will be removed. |
►
void
removeAll()
Removes all the items inside the menu.