1
votes

In a Datagrid, how to detect when the user press the key "Tab" from the last cell ? With KEY_DOWN event the selected cell is unknown, with FOCUS_OUT we don't know the key pressed.

Thanks in advance

1
I think this is a duplicate of this issue here: stackoverflow.com/questions/2133768/…Alex B.

1 Answers

0
votes

You can extend a DataGrid like this, a handle the KeyboardEvent.KEY_DOWN event

public class CustomRowColorDataGrid extends DataGrid
{

    public function CustomRowColorDataGrid()
    {
        super();
        this.addEventListener(KeyboardEvent.KEY_DOWN,keyDownHandler);
    }
    private function keyDownHandler(e:KeyboardEvent) : void
    {

        trace("onKeyDown:" + e.keyCode) ;
        //TAB is 9      
        if(e.keyCode == 9)
        {
            // your logic here
        }
    }

Or you could also declare a regular Flex grid and follow the same idea

<mx:DataGrid id="yourGrid" keyDown="keyDownHandler(event)">

</mxDataGrid>
<fx:Script>
    private function keyDownHandler(e:KeyboardEvent) : void
    {

        trace("onKeyDown:" + e.keyCode) ;
        //TAB is 9  

        if(e.keyCode == 9)
        {
            // your logic here
        }
    }
</fx:Script>