开发者

Flex : Detect "tab" key press from the last cell of a DataGrid

In a Datagrid, how to detect开发者_C百科 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


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜