View Full Version : How to Programmatically Fire END key press?

12 Feb 2010, 12:11 PM
Title is pretty much the question.

If context helps:

I have a combo box. Once you select an entry from the drop down list, in the in put box I'd like to see the end part of the chosen text instead of the beginning part. The text is longer than the input box itself. I tried selecting the last character of the text using selectText(), however while it does select the last character, it doesn't automatically scroll to that point. My theory was to focus in the input box and fire the END key to get to the end of the text. Doing this with the key board obviously works, but I'm not sure how to do it programmatically. Perhaps component.fireEvent('keypress', End-Keypress-Event)? If so how do I contruct an end keypress event?

12 Feb 2010, 1:16 PM
That's not the right way to go about it - search for set cursor position or set caret position instead.