Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Defining menu structure and data > Specifying and using menu entry information - Pg. 341

ADOBE FLEX 3 349 Adobe Flex 3 Developer Guide As with all data-driven controls, if the data provider contents can change dynamically, and you want the Menu to update with the changes, ensure that the data source is a collection, such as an ArrayCollection or XMLListCol- lection object. To modify the menu, change the underlying collection, and the menu will update its appearance accordingly. Node (menu item) tags in the XML data can have any name. Many examples in this topic use tags such as <node> for all menu items, or <menuItem> for top-level items and <subMenuItem> for submenu items, but it might be more realistic to use tag names that identify the data, such as <person>, <address> , and so on. The menu- handling code reads through the XML and builds the display hierarchy based on the nested relationship of the nodes. For more information, see "Specifying and using menu entry information" on page 349. Most menus have multiple items at the top level, not a single root item. XML objects, such as the XML object created by the <mx:XML> tag, must have a single root node. To display a menu that uses a data provider that has a root that you do not want to display, set the Menu, PopUpMenuButton, or MenuBar showRoot property to false . Specifying and using menu entry information Information in menu-based control data providers determines how each menu entry appears and is used. To access or change the menu contents, you modify the contents of the data provider. The menu-based classes use the methods of the IMenuDataDescriptor interface to access and manipulate infor- mation in the data provider that defines the menu behavior and contents. Flex provides a DefaultDataDescriptor class that implements this interface. The menu-based controls use the DefaultDataDescriptor class if you do not set the dataDescriptor property. Menu entry types Each data provider entry can specify an item type and type-specific information about the menu item. Menu- based classes support the following item types ( type field values): normal (the default) Selecting an item with the normal type triggers a change event, or, if the item has children, opens a submenu. check Selecting an item with the check type toggles the menu item's toggled property between true and false values. When the menu item is in the true state, it displays a check mark in the menu next to the item's label. radio Items with the radio type operate in groups, much like RadioButton controls; you can select only one radio menu item in each group at a time. The example in this section defines three submenu items as radio buttons within the group "one". When a radio button is selected, the radio item's toggled property is set to true , and the toggled properties of all other radio items in the group are set to false . The Menu control displays a solid circle next to the radio button that is currently selected. The selection property of the radio group is set to the label of the selected menu item.