我试图让一个带有可立即编辑的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