禁用LIST控件的键盘事件.学习重写方法.

通过重写keyDownHandler()方法实现.
示例:


代码:
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 {
        }
    }
}

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 >

源文件: http://blog.flexexamples.com/wp-content/uploads/List_keyDownHandler_test/bin/srcview/index.html

来自: http://blog.flexexamples.com/2008/06/11/disabling-keyboard-navigation-on-the-list-control-in-flex/

你可能感兴趣的:(list)