简体   繁体   中英

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;

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM