Packageflexlib.baseClasses
Classpublic class PopUpMenuButtonBase
InheritancePopUpMenuButtonBase Inheritance mx.controls.PopUpButton
SubclassesScrollablePopUpMenuButton

PopUpMenuButtonBase is a copy/paste version of the original PopUpMenuButton class in the Flex framework.

The only modifications made to this class were to change some properties and methods from private to protected so we can override them in a subclass.

The PopUpMenuButton control creates a PopUpButton control with a main sub-button and a secondary sub-button. Clicking on the secondary (right) sub-button drops down a menu that can be popluated through a dataProvider property. Unlike the Menu and MenuBar controls, the PopUpMenuButton control supports only a single-level menu. This means that the menu cannot contain cascading submenus.

The main sub-button of the PopUpMenuButton control can have a text label, an icon, or both on its face. When a user selects an item from the drop-down menu or clicks the main button of the PopUpMenuButton control, the control dispatches an itemClick event. When a user clicks the main button of the control, the control also dispatches a click event. You can customize the look of a PopUpMenuButton control.

MXML Syntaxexpanded Hide MXML Syntax

The <mx:PopUpMenuButton> tag inherits all of the tag attributes of its superclass, and adds the following tag attributes:

  <mx:PopUpMenuButton
    Properties
    dataDescriptor="instance of DefaultDataDescriptor"
    dataProvider="undefined"
    labelField="null"
    labelFunction="undefined"
    showRoot="false|true"
     
    Event
    change=No default
  />
  

See also

mx.controls.Menu
mx.controls.MenuBar


Public Properties
 PropertyDefined by
  dataDescriptor : IMenuDataDescriptor
The data descriptor accesses and manipulates data in the data provider.
PopUpMenuButtonBase
  dataProvider : Object
DataProvider for popUpMenu.
PopUpMenuButtonBase
  labelField : String
Name of the field in the dataProvider Array that contains the text to show for each menu item.
PopUpMenuButtonBase
  labelFunction : Function
A function that determines the text to display for each menu item.
PopUpMenuButtonBase
  popUp : IUIComponent
[write-only] A reference to the pop-up Menu object.
PopUpMenuButtonBase
  showRoot : Boolean
Specifies whether to display the top-level node or nodes of the data provider.
PopUpMenuButtonBase
Public Methods
 MethodDefined by
  
Constructor.
PopUpMenuButtonBase
Events
 EventSummaryDefined by
   Dispatched when a user selects an item from the pop-up menu.PopUpMenuButtonBase
Property detail
dataDescriptorproperty
dataDescriptor:IMenuDataDescriptor  [read-write]

The data descriptor accesses and manipulates data in the data provider.

When you specify this property as an attribute in MXML, you must use a reference to the data descriptor, not the string name of the descriptor. Use the following format for the property:

<mx:PopUpMenuButton id="menubar" dataDescriptor="{new MyCustomDataDescriptor()}"/>

Alternatively, you can specify the property in MXML as a nested subtag, as the following example shows:

<mx:PopUpMenuButton>
      <mx:dataDescriptor>
         <myCustomDataDescriptor>
      </mx:dataDescriptor>
      ...

The default value is an internal instance of the DefaultDataDescriptor class.

Implementation
    public function get dataDescriptor():IMenuDataDescriptor
    public function set dataDescriptor(value:IMenuDataDescriptor):void
dataProviderproperty 
dataProvider:Object  [read-write]

DataProvider for popUpMenu.

The default value is null.

This property can be used as the source for data binding.

Implementation
    public function get dataProvider():Object
    public function set dataProvider(value:Object):void
labelFieldproperty 
labelField:String  [read-write]

Name of the field in the dataProvider Array that contains the text to show for each menu item. The labelFunction property, if set, overrides this property. If the data provider is an Array of Strings, Flex uses each String value as the label. If the data provider is an E4X XML object, you must set this property explicitly; for example, use @label to specify the label attribute.

The default value is "label".

This property can be used as the source for data binding.

Implementation
    public function get labelField():String
    public function set labelField(value:String):void
labelFunctionproperty 
labelFunction:Function  [read-write]

A function that determines the text to display for each menu item. If you omit this property, Flex uses the contents of the field or attribute determined by the labelField property. If you specify this property, Flex ignores any labelField property value.

If you specify this property, the label function must find the appropriate field or fields and return a displayable string. The labelFunction property is good for handling formatting and localization.

The label function must take a single argument which is the item in the dataProvider and return a String.

labelFunction(item:Object):String

The default value is null.

Implementation
    public function get labelFunction():Function
    public function set labelFunction(value:Function):void
popUpproperty 
popUp:IUIComponent  [write-only]

A reference to the pop-up Menu object.

This property is read-only, and setting it has no effect. Set the dataProvider property, instead. (The write-only indicator appears in the syntax summary because the property in the superclass is read-write and this class overrides the setter with an empty implementation.)

Implementation
    public function set popUp(value:IUIComponent):void
showRootproperty 
showRoot:Boolean  [read-write]

Specifies whether to display the top-level node or nodes of the data provider. If this is set to false, the control displays only descendants of the first top-level node. Any other top-level nodes are ignored. You normally set this property to false for E4X format XML data providers, where the top-level node is the document object.

The default value is true.

Implementation
    public function get showRoot():Boolean
    public function set showRoot(value:Boolean):void
Constructor detail
PopUpMenuButtonBase()constructor
public function PopUpMenuButtonBase()

Constructor.

Event detail
itemClickevent 
Event object type: mx.events.MenuEvent

Dispatched when a user selects an item from the pop-up menu.