Yeah... my menus actually know which object they are invoked for. I do this by overriding the rollOver on the dataGrid and passing the row that was rolled over to the menu. So, in the MENU_SELECT the menu just finds that item in the grid and selects it (if not already selected).

hth
Scott

Scott Melby
Founder, Fast Lane Software LLC
http://www.fastlanesw.com



letterpigeon wrote:

Hi Scott,

I tried your suggestion and in my handleMenuSelectEvent, I do:

var dataGrid:DataGrid = event.contextMenuOwner as DataGrid;
dataGrid.selectedIdex = (event.mouseTarget as
DataGridItemRenderer).listData.rowIndex - 1;

but this solution does not always work, because event.mouseTarget does
not always return a DataGridItemRenderer, it somes return a
ListBaseContentHolder, in which case the above code would not work.

Are you getting the index of the row being clicked from somewhere
else? Thanks.

Ban

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>, Scott Melby <[EMAIL PROTECTED]> wrote:
>
> I did it by listening for the MENU_SELECT event on my context menu...
> works great.
>
> _myContextMenu.addEventListener(ContextMenuEvent.MENU_SELECT,
> handleMenuSelectEvent, false, 0, true);
>
> hth
> Scott
>
> Scott Melby
> Founder, Fast Lane Software LLC
> http://www.fastlanesw.com <http://www.fastlanesw.com>
>
>
>
> Alex Harui wrote:
> >
> > Search the archives for right-click. I think it has been done before.
> >
> >
> >
> >
----------------------------------------------------------
> >
> > *From:* flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
[mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>]
> > *On Behalf Of *letterpigeon
> > *Sent:* Wednesday, December 12, 2007 7:57 AM
> > *To:* flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> > *Subject:* [flexcoders] Datagrid context menu question
> >
> >
> >
> > Hi,
> >
> > I have a datagrid with a context menu. when user right click on the
> > grid, is there a way to tell which row that just get right clicked
> > (not the current selected item and right clicking on the grid doesn't
> > change the selected item). Just want to make the UI a bit more
> > intuitive (instead of making to user to left click on an item, then
> > right clicking again to action on the desired row).
> >
> > Thanks.
> >
> >
>

Reply via email to