2012-11-01 40 views
0

我有TitleWindow窗口,它具有TextInput的。雖然它是popuped我做其他操作,如從菜單上選擇頂層應用程序MenuItem。 選擇菜單項後,我需要將文本添加到之前關注的titlewindow的TextInput中。現在我得到了這些以前關注的TextInput。但是當它被聚焦時,不能找到光標或者底座位置指向的索引。在這個位置我需要插入文本。獲取TextInput的光標位置,然後將其聚焦

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

回答

1

您是否試圖傾聽注意力集中在輸入字段上,然後記錄插入符的位置?

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

還有一個例子here