Thursday, July 19, 2012

TextArea - moving focus on Return key press

If you have a TextArea in Flex with single line height and are using the Enter key to move the mouse focus to some other element, do prepare yourself to be amazed. What will happen when you click on Enter is that the mouse focus moves to the other element, but you won't be able to see any text in the TextArea.

What causes this is that TextArea is generally intended for multi-line input and so, internally it listens for the Enter key event and moves the cursor to the next line.Thus, when your text area has a single line height the text shifts upwards and out of sight.

The immediate resolution to this problem can be to use the TextInput (if you expect only single line input) or to override the textArea event handler and write your own implementation for the same.


No comments :