Friday, April 2, 2010

get current textarea line

Hi Guys

How can I get the text of the current line the cursor is on ? The following works for the last line:


?ta.validateNow();
?var textField:IUITextField = ta.mx_internal::getTextField();

?var numLines:Number = textField.numLines; // get all lines on textarea

?var lastLine:String = textField.getLineText(numLines - 1); //get lastline text

get current textarea line

You can use getLineIndexAtPoint method of TextField to get the line under certain position. Once you find the line number, you can find the text by getLineText(lineNum) method.

Here is an example to find the line number

http://stackoverflow.com/questions/980756/how-can-i-calculate-line-number-relati ve-to-cursor-postion-in-textarea-with-flex

No comments:

Post a Comment