PopUpMenuButton forwards event from it's internal Menu object. Menu only dispatches an itemClick event when the user clicks on a leaf node. You can monkey patch Menu to fire off events when an internal node is clicked by changing the mouseUpHander. By removing the check on isBranch from the line that reads
if (item != null && _dataDescriptor.isEnabled(item) && !_dataDescriptor.isBranch(item)) the Menu will behave as you expect it to (I'm using the version of the SDK that shipped with Flex Builder 3 -- if you have another build things might be different). You can then use the properties of the event to do whatever processing you needed. --- In [email protected], "sudha_bsb" <[EMAIL PROTECTED]> wrote: > > Hi, > > I am having strange problem with PopupMenuButton. I am having a > popupmenubutton with submenus as its items. > > When I click on the parent menu item( not on the sub menu item), how > can i get the index of the parent menu item on which it is clicked. > Which event gets triggered for this. The itemClick event is triggered > only when we click on the sub menu item which is in the last hierarchy. > > Similarly when i click on the submenu item, i need the index of its > parent menu with respect to popumenu button. > > Here is the code... > > When I click on Inbox or Calendar menu......i need its index(0 or > 1)......Similarly when I click on Personal menu item...I need Inbox > index(its parent menu index.) > > Please help.... > > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > layout="absolute"> > > <mx:Script> > <![CDATA[ > import mx.events.*; > import mx.controls.*; > > //Event handler, invoked when you select from the menu. > public function itemClickHandler2(event:MenuEvent):void { > Alert.show("Menu label: " + event.label > + " \n menu item index within parent menu: " + > event.index); > } > ]]> > </mx:Script> > > <!-- A an data provider in E4X format. --> > <mx:XMLList id="treeDP2"> > <node label="Inbox"> > <node label="Personal" /> > <node label="Marketing"/> > <node label="To Do"/> > </node> > <node label="Calendar"> > <node label="Appointments" data="6"/> > <node label="Meetings"/> > </node> > <node label="Deleted Items"/> > </mx:XMLList> > > <mx:Panel title="PopUpMenuButton Control Example" > paddingTop="10" paddingLeft="10" paddingRight="10" x="10" > y="205" height="143" width="271"> > > <mx:Label width="100%" color="blue" > text="Click the down arrow to open the menu."/> > > <mx:PopUpMenuButton id="p2" > dataProvider="{treeDP2}" > labelField="@label" > itemClick="itemClickHandler2(event);"/> > > </mx:Panel> > > </mx:Application> > > Thanks, > Sudha. >

