mx.controls
Class MenuBar



class MenuBar
extends mx.core.UIComponent

The MenuBar control defines a horizontal menu bar that contains one or more submenus. The MenuBar control is static: it does not pop up, but rather is always visible in your application.

MXML Syntax

The <mx:MenuBar> tag inherits all the properties of its parent classes, and the following properties:

 <mx:MenuBar
dataProvider="No default."
labelField="No default."
menuHide="Event handler. No default."
change="Event handler. No default."
menushow="Event handler. No default."
rollOut="Event handler. No default."
rollOver="Event handler. No default."
/>



Methods
      addMenu(arg1, arg2) : Menu
Adds a single menu to the end of MenuBar control and returns the index of the new menu in the MenuBar control.
      addMenuAt(index, arg1, arg2) : Void
Adds a menu to the MenuBar control at the specified location.
      getMenuAt(index) : Menu
Returns a reference to the menu item as the specified index.
      getMenuEnabledAt(index) : Void
Returns true if the menu item at the specified index is enabled.
      init() : Void
Generic initializer.
      labelFunction
Function that determines what displays as the text for each menu item.
      removeMenuAt(index) : Menu
Removes the specified menu from the MenuBar control.
      setDataProvider(dp) : Void
Loads the state from the given XMLNode object.
      setMenuEnabledAt(index, enable) : Void
Enables the menu item at the specified index.

Methods inherited from class mx.core.UIComponent
getFocus  setFocus  getFocusManager 

Methods inherited from class mx.core.UIObject
createAccessibilityImplementation  measure  doLater  cancelAllDoLaters  invalidate  invalidateStyle  invalidateProperties  invalidateSize  redraw  move  setSize  setSizeNoLayout  drawRect  fillRect  destroyLabel  createClassObject  createEmptyObject  destroyObject  getStyle  setMask  swapDepths 


Properties
staticversion:String  
ComponentVersion is for internal use only.
      labelField:String   [Read-Write]
Name of the field in the dataProvider Array to use as the text for each menu item.
      dataProvider:Object   [Read-Write]
Array of simple types or Objects.

Properties inherited from class mx.core.UIComponent
version  enabled  tabIndex 

Properties inherited from class mx.core.UIObject
version  nestLevel  dispatchEvent  addEventListener  handleEvent  removeEventListener  kStretch  styleName  className  setStyle  parentApplication  isDocument  parentDocument  documentDescriptor  descriptor  instanceIndices  repeaterIndices  getRepeaterItem  id  width  height  x  y  minHeight  minWidth  preferredHeight  preferredWidth  maxHeight  maxWidth  widthFlex  heightFlex  visible  scaleX  scaleY  alpha  depth  mouseX  mouseY  toolTip  baselinePosition 


Effects

Effects inherited from class mx.core.UIComponent
showEffect  hideEffect  focusInEffect  focusOutEffect 

Effects inherited from class mx.core.UIObject
creationCompleteEffect  moveEffect  resizeEffect  mouseDownEffect  mouseOverEffect  mouseOutEffect  mouseUpEffect 


Events
menuShowBroadcast when the entire menu or a submenu opens. The event object contains the properties:
- menuBar MenuBar instance that is the parent of the selected Menu control, or undefined when the target Menu control does not belong to a MenuBar control.
Target contains a reference to the component that triggered the event. Type contains the name of the event.
menuHideBroadcast when a menu closes. The event object contains the properties: - menuBar MenuBar instance that is the parent of the selected Menu control, or undefined when the target Menu control does not belong to a MenuBar control.
- menu Menu instance that was hidden, of type Menu.
Target contains a reference to the component that triggered the event. Type contains the name of the event.
rollOverBroadcast when the cursor rolls over a Menu item. The event object contains the properties: - menuItem The selected menu item. Access the menu item properties as:
eventobj.menuItem.attributes.attribName

Target contains a reference to the component that triggered the event. Type contains the name of the event.
rollOutBroadcast when the cursor rolls off of a Menu item. The event object contains the properties:
- menuItem The selected menu item. Access the menu item properties as:
eventobj.menuItem.attributes.attribName 
Target contains a reference to the component that triggered the event. Type contains the name of the event.
changeBroadcast when a user selects an item in the Menu control. The event object contains the properties: - menuBar MenuBar instance that is the parent of the selected Menu control, or undefined when the target Menu control does not belong to a MenuBar control.
- menu Menu instance that was hidden, of type Menu.
- menuItem Selected menu item. Access the menu item properties as: eventobj.menuItem.attributes.attribName
- groupName Name of the radio group to which the item belongs. Undefined when the target item is not in a radio group. The data type is String.
Target contains a reference to the component that triggered the event. Type contains the name of the event.

Events inherited from class: mx.core.UIComponent
focusIn  focusOut  keyDown  keyUp  show  hide  valid  invalid  valueCommitted 

Events inherited from class: mx.core.UIObject
initialize  creationComplete  resize  move  draw  load  unload  mouseDown  mouseUp  mouseMove  mouseOver  mouseOut  mouseDownSomewhere  mouseUpSomewhere  mouseMoveSomewhere  mouseChangeSomewhere  effectStart  effectEnd  dragBegin  dragComplete  dragEnter  dragOver  dragExit  dragDrop 


Styles
rollOverColor Type: Number   Format: Color   CSS Inheritance: yes
Color of the background when the link is rolled over. The default value is #0E#FFD6.
selectionColor Type: Number   Format: Color   CSS Inheritance: yes
Color of the background when the link is selected. The default value is #0DFFC1.

Styles inherited from class mx.core.UIComponent
backgroundColor  backgroundDisabledColor  backgroundImage  backgroundAlpha  backgroundSize  barColor  borderCapColor  borderColor  buttonColor  borderStyle  disabledColor  errorColor  highlightColor  lineHeight  modalTransparency  scrollTrackColor  shadowColor  shadowCapColor  symbolColor  symbolBackgroundColor  symbolBackgroundDisabledColor  symbolBackgroundPressedColor  symbolDisabledColor  themeColor 

Styles inherited from class mx.core.UIObject
color  fontFamily  fontSize  fontStyle  fontWeight  textAlign  textDecoration  textIndent  marginLeft  marginRight  horizontalGap  verticalGap 


Method Detail

addMenu

addMenu(arg1, arg2) : Menu

Adds a single menu to the end of MenuBar control and returns the index of the new menu in the MenuBar control.

Parameters
     arg1 - May be either: a String, which is the item`s label; or an xmlNode.
     arg2 - May be: undefined; a menu; or an xml/xmlNode.

Returns
     Reference to the new Menu.


addMenuAt

addMenuAt(index, arg1, arg2) : Void

Adds a menu to the MenuBar control at the specified location.

Parameters
     index - Index where the menu should be inserted.
     arg1 - May be either:a String, which is the item`s label; or an xmlNode.
     arg2 - May be: undefined; a menu; or an xml/xmlNode.

Returns
     The reference to the new Menu.


getMenuAt

getMenuAt(index) : Menu

Returns a reference to the menu item as the specified index.

Parameters
     index - Index of the menu instance to return.

Returns
     Reference to the menu at the specified index.


getMenuEnabledAt

getMenuEnabledAt(index) :  Void

Returns true if the menu item at the specified index is enabled.

Parameters
     index - Index of the menu instance.

Returns
     Boolean of the enabled state of the specified menu.


init

init() : Void

Generic initializer.


labelFunction

labelFunction() :  Void

Function that determines what displays as the text for each menu item. The function accepts the XML node associated with an item as a parameter, and returns a string used as label text. This property is propagated to any menus created from the MenuBar.


removeMenuAt

removeMenuAt(index) : Menu

Removes the specified menu from the MenuBar control.

Parameters
     index - Index of the menu instance to remove.

Returns
     Reference to the menu that was removed.


setDataProvider

setDataProvider(dp) :  Void

Loads the state from the given XMLNode object.

Parameters
     dp - DataProvider.


setMenuEnabledAt

setMenuEnabledAt(index, enable) :  Void

Enables the menu item at the specified index.

Parameters
     index - Index of the menu instance to enable.
     enable - Whether to enable the menu on the MenuBar.


Property Detail

dataProvider

dataProvider:Object   [Read-Write]

Array of simple types or Objects.


labelField

labelField:String   [Read-Write]

Name of the field in the dataProvider Array to use as the text for each menu item. If omitted, the data provider must contain a field named label, or the dataProvider property must contain an Array of Strings.


version

static version:String  

ComponentVersion is for internal use only.