Packageflexlib.baseClasses
Classpublic class PopUpMenuButtonBase
InheritancePopUpMenuButtonBase Inheritance mx.controls.PopUpButton
Subclasses ScrollablePopUpMenuButton

PopUpMenuButtonBase is a copy/paste version of the original PopUpMenuButton class in the Flex framework. <p>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.</p> <p>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 <codeph>dataProvider</codeph> 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.</p> <p>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 <codeph>itemClick</codeph> event. When a user clicks the main button of the control, the control also dispatches a <codeph>click</codeph> event. You can customize the look of a PopUpMenuButton control.</p> <p>The PopUpMenuButton control has the following sizing characteristics:</p> <adobetable class="innertable"> <tgroup cols="2"><thead><row><entry>Characteristic</entry><entry>Description</entry></row></thead><tbody><row> <entry>Default size</entry> <entry>Sufficient to accommodate the label and any icon on the main button, and the icon on the pop-up button. The control does not reserve space for the menu.</entry> </row><row> <entry>Minimum size</entry> <entry>0 pixels.</entry> </row><row> <entry>Maximum size</entry> <entry>10000 by 10000.</entry> </row></tbody></tgroup></adobetable>

MXML SyntaxexpandedHide MXML Syntax
<p>The <code>&lt;mx:PopUpMenuButton&gt;</code> tag inherits all of the tag attributes of its superclass, and adds the following tag attributes:</p> <pre> &lt;mx:PopUpMenuButton <strong>Properties</strong> dataDescriptor="<i>instance of DefaultDataDescriptor</i>" dataProvider="undefined" iconField="icon" iconFunction="undefined" labelField="label" labelFunction="undefined" showRoot="false|true" &nbsp; <strong>Event</strong> change=<i>No default</i> /&gt; </pre>

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
  iconField : String
Name of the field in the dataProvider Array that contains the icon to show for each menu item.
PopUpMenuButtonBase
  iconFunction : Function
A function that determines the icon to display for each menu item.
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
[override] [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
 Event Summary Defined By
  Dispatched when a user selects an item from the pop-up menu.PopUpMenuButtonBase
Styles
 Style Description Defined By
  
popUpStyleName
Type: String CSS Inheritance: no
The name of a CSS style declaration used by the dropdown menu. This property allows you to control the appearance of the dropdown menu. The default value sets the fontWeight to normal and the textAlign to left. The default value is "popUpMenu".
PopUpMenuButtonBase
Property Detail
dataDescriptorproperty
dataDescriptor:IMenuDataDescriptor

The data descriptor accesses and manipulates data in the data provider. <p>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:</p> <pre><mx:PopUpMenuButton id="menubar" dataDescriptor="{new MyCustomDataDescriptor()}"/></pre> <p>Alternatively, you can specify the property in MXML as a nested subtag, as the following example shows:</p> <pre><mx:PopUpMenuButton> <mx:dataDescriptor> <myCustomDataDescriptor> </mx:dataDescriptor> ...</pre> <p>The default value is an internal instance of the DefaultDataDescriptor class.</p>


Implementation
    public function get dataDescriptor():IMenuDataDescriptor
    public function set dataDescriptor(value:IMenuDataDescriptor):void
dataProviderproperty 
dataProvider:Object

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
iconFieldproperty 
iconField:String

Name of the field in the <codeph>dataProvider</codeph> Array that contains the icon to show for each menu item. The <codeph>iconFunction</codeph> property, if set, overrides this property. <p>The renderers will look in the data provider object for a property of the name supplied as the iconField. If the value of the property is a Class, it will instantiate that class and expect it to be an instance of an IFlexDisplayObject. If the value of the property is a String, it will look to see if a Class exists with that name in the application, and if it can't find one, it will also look for a property on the document with that name and expect that property to map to a Class.</p> If the data provider is an E4X XML object, you must set this property explicitly; for example, use @icon to specify the <codeph>icon</codeph> attribute.

The default value is "icon".

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


Implementation
    public function get iconField():String
    public function set iconField(value:String):void
iconFunctionproperty 
iconFunction:Function

A function that determines the icon to display for each menu item. If you omit this property, Flex uses the contents of the field or attribute determined by the <codeph>iconField</codeph> property. If you specify this property, Flex ignores any <codeph>iconField</codeph> property value. By default the menu does not try to display icons with the text in the rows. However, by specifying an icon function, you can specify a Class for a graphic that will be created and displayed as an icon in the row. <p>The iconFunction takes a single argument which is the item in the data provider and returns a Class.</p> <blockquote> <codeph>iconFunction(item:Object):Class</codeph> </blockquote>

The default value is null.


Implementation
    public function get iconFunction():Function
    public function set iconFunction(value:Function):void
labelFieldproperty 
labelField:String

Name of the field in the <codeph>dataProvider</codeph> Array that contains the text to show for each menu item. The <codeph>labelFunction</codeph> 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 <codeph>label</codeph> 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

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 <codeph>labelField</codeph> property. If you specify this property, Flex ignores any <codeph>labelField</codeph> property value. <p>If you specify this property, the label function must find the appropriate field or fields and return a displayable string. The <codeph>labelFunction</codeph> property is good for handling formatting and localization.</p> <p>The label function must take a single argument which is the item in the dataProvider and return a String.</p> <blockquote> <codeph>labelFunction(item:Object):String</codeph> </blockquote>

The default value is null.


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

A reference to the pop-up Menu object. <p>This property is read-only, and setting it has no effect. Set the <codeph>dataProvider</codeph> 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.)</p>


Implementation
    public function set popUp(value:IUIComponent):void
showRootproperty 
showRoot:Boolean

Specifies whether to display the top-level node or nodes of the data provider. If this is set to <codeph>false</codeph>, the control displays only descendants of the first top-level node. Any other top-level nodes are ignored. You normally set this property to <codeph>false</codeph> 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
itemClick Event
Event Object Type: mx.events.MenuEvent
MenuEvent.type property = mx.events.MenuEvent.ITEM_CLICK

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