Search code examples
actionscript-3apache-flexflex4

How to disable keyboard navigation on a Spark List?


The keyboard interaction on my list is causing it to jump between different list items. The list should only respond to mouse events so I'd like to turn off keyboard handling.

I found this method which overrides the List class but I'd like to know if there's another method.


Solution

  • Here's the extended class override:

    import flash.events.KeyboardEvent;
    
    import spark.components.List;
    
    public class ListNoKeyboardHandling extends List
    {
        public function ListNoKeyboardHandling()
        {
            super();
        }
    
        override protected function keyDownHandler(event:KeyboardEvent):void {
            // do nothing
        }
    }