11
Jun
08

Disabling keyboard navigation on the List control in Flex

In a previous example, “Disabling keyboard navigation on the Accordion container in Flex”, we saw how to disabe keyboard navigation on the Flex Accordion container by overriding the keyDownHandler() method.

The following example shows how you can disable keyboard navigation on the Flex List control by extending the List class and overriding the protected keyDownHandler() method.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/06/11/disabling-keyboard-navigation-on-the-list-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        xmlns:comps="comps.*"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Array id="arr">
        <mx:Object label="One" />
        <mx:Object label="Two" />
        <mx:Object label="Three" />
        <mx:Object label="Four" />
        <mx:Object label="Five" />
        <mx:Object label="Six" />
        <mx:Object label="Seven" />
        <mx:Object label="Eight" />
        <mx:Object label="Nine" />
    </mx:Array>

    <comps:MyList id="list"
            dataProvider="{arr}"
            width="100" />

</mx:Application>

comps/MyList.as

/**
 * http://blog.flexexamples.com/2008/06/11/disabling-keyboard-navigation-on-the-list-control-in-flex/
 */
package comps {
    import flash.events.KeyboardEvent;
    import mx.controls.List;

    public class MyList extends List {
        public function MyList() {
            super();
        }

        override protected function keyDownHandler(event:KeyboardEvent):void {
        }
    }
}

View source is enabled in the following example.


2 Responses to “Disabling keyboard navigation on the List control in Flex”


  1. 1 小小菜鸟 Jun 12th, 2008 at 8:34 pm

    thanks for you tutorials~ very userful!@

  2. 2 jose luis garcia Jun 13th, 2008 at 10:31 am

    Thank you for your tutorials.

    It’s possible to set a handCursor to a DataGrid Control?

    I mean not only the Headers but the list too, preserving the list properties like the roll over and the selected Item color while using the hand cursor on the rows.

    Thank you for your time.

Leave a Reply

This blog is terrible at eating HTML tags. If you plan on posting code/XML, please escape your "<" characters as "&lt;" and your ">" characters as "&gt;".