PDA

View Full Version : Text Input - Find Cursor Position


pattyg
01-11-2006, 08:11 PM
Hello -
I am building an application in which users can use a "Character Panel" to insert non-keyboard characters (such as É, À, ó, etc) into the focused text input component. I would like to insert these characters when the users press the associated button into the focused component's text after the current cursor position. I would also like to be able to detect if the user has text "selected" in the Text Input component - hence replacing the selected text with the proper character.

Is there an easy way to detect the cursor position/selected text in a text input component?

Thanks for your help in advance,
Patrick

MTempsNH
05-18-2007, 08:01 PM
To get the current cursor position in a textbox try copying this into your code.


stop();
//
function traceText(){
trace(Selection.getBeginIndex());
}
var newInterval = setInterval(traceText, 1000);


Then if you wanted to insert something, simple slice the string in two, add your item after the first slice, then add the second slice on.