0 Replies Latest reply on Aug 21, 2007 1:51 AM by viewtifulcat

    How to prevent arrow keys (up, down, etc) process in textinput/combo box?

    viewtifulcat
      I am writing a flex application with several textinputs and combo boxes to build an order form. I want to use arrow keys (up, down/enter) to navigate between form items instead of pressing tab and shift-tab. I ran into a problem that when the focus is in combo box. The application will select next item inside combo box when i press "down" instead of setting focus to next form item. I tried to add listener to KeyboardEvent.KEY_DOWN event and use preventDefault() but it doesn't work at all... I can prevent character input int textinput event by preventDefault, but the keyboard event one can't be block:

      public class orderTextInput extends TextInput
      {
      public function orderTextInput(){
      super();
      addEventListener(TextEvent.TEXT_INPUT,textInputHandler,true);
      addEventListener(Event.CHANGE, changeHandler);
      addEventListener(KeyboardEvent.KEY_DOWN, kDownHandler, true);
      }

      private function changeHandler(evt:Event):void{
      evt.preventDefault();
      }

      private function kDownHandler(evt:KeyboardEvent):void{
      evt.preventDefault();
      evt.stopImmediatePropagation();
      evt.stopPropagation();
      }
      }

      please help... i am stucked in this for 3 days. Thanks a lot~