我試圖讓一個帶有可立即編輯的TextInput的彈出窗口。這意味着一旦顯示彈出窗口,用戶應該能夠在TextInput內輸入內容。將焦點設置在Popup的textInput控件上
問題是我無法專注於textInput。會發生什麼情況是,當第一次按下某個鍵時,不會插入文本,只有在按下第二個鍵之後,該組件纔會獲得焦點並且用戶才能夠輸入。例如,一旦彈出窗口打開導致顯示「est」,就會輸入「test」...
由於某些原因,組件僅在用戶明確點擊或鍵入內容時獲得焦點。 Programmaticaly設置焦點不起作用。
任何意見/建議?
代碼:
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns="mog.miss.component.*" xmlns:mx="http://www.adobe.com/2006/mxml" >
<mx:Script>
<![CDATA[
import mx.managers.IFocusManagerComponent;
private function focus():void{
focusManager.setFocus(commentTextInput as IFocusManagerComponent);
commentTextInput.setSelection(commentTextInput.text.length,commentTextInput.text.length);
}
]]>
</mx:Script>
<mx:TextInput id="commentTextInput" creationComplete="{focus()}" />
</mx:Panel>
你有彈出 – Grumpy 2010-07-27 11:04:48