小小菜鸟的web菜园子

web开发学习。好记性不如烂笔头。每天进步一点点!

导航

禁用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/

posted on 2008-06-13 11:37  『小小菜鸟』  阅读(522)  评论(0编辑  收藏  举报