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.
<?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>
/**
* 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.



{ 6 comments… read them below or add one }
thanks for you tutorials~ very userful!@
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.
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
Hi Peter,
thanks a lot for this example.
Unfortunatly when I try to use a TileLayout in my CustomList I get the following Error: Could not resolve <s:layout> to a component implementation.
I’m a bit confused about the Namespaces here…
Just found the Namespace solution.
Use the same Namespace for the <components:layout> tag as for your custom component.
How can I override the enter key behavior on a Datagrid? I’m assuming there like a enterHandler() method I can override, but can’t find any documentation on it.
Thanks!