0
votes

I'm trying to catch when a user presses a "enter" key in a rich editable text field. It wasn't dispatching KeyboardEvent.KEY_DOWN so I found that it dispatches an "enter" key event. That seemed more appropriate but that is not getting dispatched either.

Here is my code:

editableRichTextField.addEventListener(FlexEvent.ENTER, commitTextEditorValues, false, 0, true);

Am I missing something?

2

2 Answers

2
votes

NB: This is with Apache Flex 4.14.

I knocked up a sample application for this and it seemed that the RichEditableText does dispatch KeyboardEvent.KEY_DOWN. How are you catching it? The following code:

private function CCH():void
{
  richEditableText.addEventListener(KeyboardEvent.KEY_DOWN, KeyDownHandler);
}

private function KeyDownHandler(event:KeyboardEvent):void
{
  if (event.keyCode == Keyboard.ENTER)
  {
      Alert.show("Enter Key Pressed");
  }
}

should trigger an alert (where the CCH method is the creation complete handler for the component/application.

0
votes

You have to set multiline to false for the event to be dispatched. This is not helpful if you need to support multiple lines so you have to use @DaJobat's answer and listen on key down.

editableRichTextField.multiline = false;