Get the XY position of the caret in TextArea

I need to get the XY position of the caret in textArea.

I already found a way to get the Y, but i dont know how to get X, can anyone help?

If any1 want to know, this is how i get Y:

var textBeforeCaret:String = text.substr(0, caretIndex);
var textDump:String = this.text;
this.text = textBeforeCaret;
this.validateNow();
yVariable = this.textHeight;
this.text = textDump;

Answers


After checking the link from RafH, i did this:

var popUpX:int = 0;
var popUpY:int = 0;
if(text.length > 0){

if(caretIndex > 0){
                                if(this.textField.getCharBoundaries(caretIndex -1) != null){
popUpX = this.textField.getCharBoundaries(caretIndex - 1).right;
popUpY = this.textField.getCharBoundaries(caretIndex - 1).bottom;
}
else{
popUpX = 0;
var i:int = 2;
                                    while(this.textField.getCharBoundaries(caretIndex - i) == null && caretIndex - i > -1){
i++;
}
if(caretIndex - i > -1){
popUpY = this.textField.getCharBoundaries(caretIndex - i).bottom + i * 10;
}
else{
popUpY = i * 10;
}
}
}
else{
popUpX = this.textField.getCharBoundaries(caretIndex).right;
popUpY = this.textField.getCharBoundaries(caretIndex).bottom;
}
}
else{
popUpX = 0;
popUpY = 0;
}

it isnt perfect, but its good enough for me


Need Your Help

Align variable height child div to bottom of variable height parent div, while another child pushes it down

html css html5 css3

The title is probably more complex than the idea itself. Below is an image showing what I need. There are simple rules:

Debug Error in Ruby script

ruby-on-rails debugging code-snippets

I'm very new to Ruby. I have the following piece of code which is giving me an error.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.