Constructor
new MenuComponent(dataObjectopt, optionsopt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
dataObject |
DataModel |
<optional> |
null | |
options |
Object |
<optional> |
null |
Example
const menuComponent = new MenuComponent()
menuComponent.appendMenuItem(new MyMenuItemComponent(...))
menuComponent.appendMenuItem(new MyMenuItemComponent(...))
menuComponent.appendMenuItem(new MyMenuItemComponent(...))
menuComponent.addListener(MenuComponent.SelectedEvent, (eventName, menuComponent, selectedIndex) => {
const menuItemComponent = menuComponent.menuItems[selectedIndex]
})
menuComponent.addListener(ToggleComponent.ToggleEvent, (eventName, menuComponent, isOpen) => {
// react to the change here
})
Members
menuItems :Array.<Component>
Type:
- Array.<Component>
opened :boolean
true if the toggle component is open
Type:
- boolean
selectedIndex :number
Type:
- number
selectedIndex
toggleComponent :ToggleComponent
Type:
Methods
appendMenuItem(component)
Parameters:
Name | Type | Description |
---|---|---|
component |
Component | A menu item Component to add to the menu |
close()
Close the toggle component
open()
Open the toggle component
toggle(open)
Toggle the toggle component open or closed
Parameters:
Name | Type | Description |
---|---|---|
open |
boolean |
toggleMenuItemVisibility(index, visible)
Parameters:
Name | Type | Description |
---|---|---|
index |
number | the index of the menu item to toggle |
visible |
boolean | whether to show or hide the menu item |