Disabling keyboard navigation on the List control in Flex

by Peter deHaan on June 11, 2008

in List

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.

{ 3 comments… read them below or add one }

1 小小菜鸟 June 12, 2008 at 8:34 pm

thanks for you tutorials~ very userful!@

Reply

2 jose luis garcia June 13, 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.

Reply

3 Krishna October 5, 2008 at 10:44 pm

Thank you for your tutorial.

Here I have one requirement i.e. I need to disable alt key and their combinations like f4, tab and also Esc key. I am implementing flex application as Desktop Application (runs in AIR).

Please tell me how can I disable these keys.

Regards,
Krishna

Reply

Leave a Comment

Sorry, this blog is terrible at eating HTML comments.
If you're pasting any HTML/XML/MXML code, you need to convert your < characters to &lt; and your > characters to &gt; .

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree

Previous post:

Next post: