Avg. Rating 3.4

Problem

In my current project, I use Context (right-click) Menus on several List-based components (DataGrid, Tree). I wanted to be able to select the item I the mouse was over when I right-clicked it to show the Context Menu.

Solution

I used built-in functions of ListBase to find the index of the item being "selected" and selected it.

Detailed explanation

I am currently working on building a User Interface (UI) for configuring custom reports using Flex. This UI has several List-based components (Tree, DataGrid, List) which use Context Menus to allow the user to perform actions on the underlying data provider of the component. For example, one component has right-click options to add a new item, edit the selected item, delete the selected item, etc.. I wanted these components to mimic desktop application functionality by allowing users to right-click on an item in the List to show the Context Menu and act. There is nothing built-in to Flex to allow this.

So, I added a Context Menu Event Listener/Handler that gets the index of the item renderer that was right-clicked, and then selects that index in the list.

See attached example application/source.

Report abuse

Related recipes