Sushant
Sushant

Reputation: 635

Get Cursor Postion of TextInput before it was focused out

I have Titlewindow Window having TextInput's. While it is popuped i do other operation like selecting MenuItem from Menu which is on toplevel application. After selecting the menuitem i need to add text to TextInput of titlewindow which was previously focused. Now i get these previously focused TextInput. But cant found the index where the cursor or carret position was pointing when it was focused. At this position i need to insert text.

 var window:Window = FlexGlobals.topLevelApplication.window;
 window.focusManager.activate();
 var textInput:TextInput = window.focusManager.getFocus() as TextInput;

Upvotes: 0

Views: 423

Answers (1)

Have you tried to listen to focus out on the input fields and then record caret position?

textInput.addEventListener(FocusEvent.FOCUS_OUT, internal_onFocusOutHandler, false, 0, true);
protected function internal_onFocusOutHandler(e:FocusEvent):void
{
   trace(textInput.selectionBeginIndex()+","+textInput.selectionEndIndex());
}

there is also an example here

Upvotes: 0

Related Questions