小小菜鸟的web菜园子

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

导航

屏蔽掉Accordion控件的键盘事件.

通过重写keyDownHandler()方法实现。



comps/MyAccordion.as   :

/**
 * http://blog.flexexamples.com/2008/06/10/disabling-keyboard-navigation-on-the-accordion-container-in-flex/
 */
package comps {
    import mx.containers.Accordion;
    import flash.events.KeyboardEvent;

    public class MyAccordion extends Accordion {
        public function MyAccordion() {
            super();
        }

        override protected function keyDownHandler(evt:KeyboardEvent):void {
        }
    }
}

MXML:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/06/10/disabling-keyboard-navigation-on-the-accordion-container-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        xmlns:comps
="comps.*"
        layout
="vertical"
        verticalAlign
="middle"
        backgroundColor
="white">

    
<comps:MyAccordion id="accordion"
            width
="100%"
            height
="100%">
        
<mx:VBox id="v1"
                label
="One"
                width
="100%"
                height
="100%">
            
<mx:Label text="One" />
        
</mx:VBox>
        
<mx:VBox id="v2"
                label
="Two"
                width
="100%"
                height
="100%">
            
<mx:Label text="Two" />
        
</mx:VBox>
        
<mx:VBox id="v3"
                label
="Three"
                width
="100%"
                height
="100%">
            
<mx:Label text="Three" />
        
</mx:VBox>
        
<mx:VBox id="v4"
                label
="Four"
                width
="100%"
                height
="100%">
            
<mx:Label text="Four" />
        
</mx:VBox>
        
<mx:VBox id="v5"
                label
="Five"
                width
="100%"
                height
="100%">
               
<mx:Label text="Five" />
        
</mx:VBox>
    
</comps:MyAccordion>

</mx:Application>

posted on 2008-06-12 12:09  『小小菜鸟』  阅读(630)  评论(0编辑  收藏  举报