我想把重点放在TextInput上:按下按钮后这个工作正常,但是当我按下TextInput上的ENTER按钮时,doers无法正常工作:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
public function sendText():void {
txt_input.enabled = false;
trace(txt_input.text);
txt_input.text = "";
setTimeout(function ():void {
txt_input.enabled = true;
focusManager.setFocus(txt_input );
}
,3000);
}
]]>
</fx:Script>
<s:TextInput id="txt_input" x="173" y="330" enter="sendText()"/>
<s:Button x="345" y="331" label="Button" click="sendText()"/>
</s:Application>
答案 0 :(得分:1)
不是将焦点转移到Ashish代码中的其他组件,而是替换
focusManager.setFocus(BTN);与
stage.focus = null;
答案 1 :(得分:0)
我之前遇到过同样的问题。我并不完全知道框架内部的内容,但我只是将焦点设置为另一个组件来完成我的工作。我知道这不是正确的方法。
在你的情况下:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
public function sendText():void {
txt_input.enabled = false;
focusManager.setFocus(btn);
trace(txt_input.text);
txt_input.text = "";
setTimeout(function ():void {
txt_input.enabled = true;
focusManager.setFocus(txt_input );
}
,3000);
}
]]>
</fx:Script>
<s:TextInput id="txt_input" x="173" y="330" enter="sendText()"/>
<s:Button id="btn" x="345" y="331" label="Button" click="sendText()"/>
</s:Application>
我认为之前没有用,因为它与“启用”属性有关。
希望它有所帮助。