public class UndoTextArea extends TextArea
    {
        
        private var _undoManager:UndoManager;
        
        public function UndoTextArea()
        {
            super();
            
            _undoManager=new UndoManager();
            
            this.addEventListener(KeyboardEvent.KEY_UP,undoKeyUpHandler);
            this.addEventListener(FlexEvent.CREATION_COMPLETE,creationCompleteHandler);
        }
        
        private function creationCompleteHandler(evt:FlexEvent):void 
        { 
            
            this.textFlow.interactionManager=new EditManager(this._undoManager);
            
        }
        
        private function undoKeyUpHandler(evt:KeyboardEvent):void 
        { 
            
            if (evt.ctrlKey&&evt.keyCode == 90) 
            { 
                _undoManager.undo();
                
            } 
            
        } 
    }
 
这里使用了KEY_UP事件,其实更合理的是用KEY_DOWN,只是在IE下CTRL-Z被浏览器截获了,我们的程序捕获不到!
 

相关文章:

  • 2021-10-10
  • 2021-10-11
  • 2022-12-23
  • 2022-12-23
  • 2021-07-04
  • 2022-12-23
  • 2021-09-25
猜你喜欢
  • 2021-08-08
  • 2022-12-23
  • 2021-09-16
  • 2021-08-11
  • 2022-12-23
  • 2022-12-23
  • 2021-11-10
相关资源
相似解决方案