all groups > flash actionscript > april 2006 >
You're in the

flash actionscript

group:

GetCurrSel ?


GetCurrSel ? David Fostor
4/28/2006 10:17:47 PM
flash actionscript:
Can anyone suggest a reasonable way to determine what the current insertion
point or selection range is in an Input Text field? E.g. if the user clicks in
the middle of the field, so that the blinking cursor is between the 3rd and 4th
character that they typed in, how can I get that location via ActionScript?

Thanks!

David
Re: GetCurrSel ? David Fostor
4/29/2006 5:03:00 PM
(And btw, if anyone has beat their head against this wall before, and decided there's no way to do it, I would appreciate hearing that too!)
Re: GetCurrSel ? RazvanPat
7/6/2006 12:00:00 AM
This is quite tricky but it can be done...
You have to create an invisible movieclip behind the text field so that you
can catch mouse events(_alpha=0)



var mc:MovieClip;
var txt:TextField;

var selStart;
var selEnd;
var cursorPos;

mc.onRelease = function()
{
_root.selStart = Selection.getBeginIndex();
_root.selEnd = Selection.getEndIndex();
_root.cursorPos = Selection.getCaretIndex();
}
AddThis Social Bookmark Button