Hi Pablo,

 

First, you need to use the itemRollOver event of the <mx:tree> component to
track the last item that was rolled over, and save it to a variable for
later use. Then when the ContextMenuEvent.MENU_SELECT event is triggered,
you will refer back to this variable as it holds a reference to the
itemRenderer and therefore the data you need access to.

 

I put a working example with source code up for you at the following url:

http://michael.omnicypher.com/2007/02/flex-trees-with-context-menu_14.html

 

Hope this helps and have a great day,

Michael

 

  _____  

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Pablo
Sent: Wednesday, February 14, 2007 11:39 AM
To: [email protected]
Subject: [flexcoders] Right click on Tree's item

 

I have the Tree and ContextMenu associated with it. When I select menu item
from context menu I cant get Tree's item was right-clicked. How I can get
this Tree's item?

            import mx.controls.listClasses.* ;

            private function createContextMenu():void
            {
                m = new ContextMenu();
                m.hideBuiltInItems();
                var customItemsArr:Array = new Array();
                var buy:ContextMenuItem = new ContextMenuItem("Detailed");
                buy.addEventListener("menuItemSelect", buyHandler);
                customItemsArr.push(buy);
                m.customItems = customItemsArr;
                callTree.contextMenu=m;
            }
            
            private function buyHandler(e:ContextMenuEvent):void
            {
                trace(e.mouseTarget);
                trace(ListBaseContentHolder(e.mouseTarget).owner);
                trace(ListBaseContentHolder(e.mouseTarget).name);
                trace(ListBaseContentHolder(e.mouseTarget).instanceIndex);
            }

in traces my trying to catch the Tree's item...

 

Reply via email to