如何将光标放在 Flex3 中的文本输入中 [英] how to place cursor in textinput in Flex3
本文介绍了如何将光标放在 Flex3 中的文本输入中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当用户登录表单出现时如何将光标置于文本输入中.我想在用户名文本输入中放置光标..任何帮助是极大的赞赏!
how to place cursor in a text input when user login form comes. I want cursor place in username text input. .Any help is greatly appreciated!
推荐答案
为了配合 J_A_X 的回答,如果您试图在应用程序首次加载时将焦点设置在组件上,您还需要 使用一些 javascript 将焦点设置在您的SWF.
To go along with J_A_X's answer, if you're trying to set focus on a component when the application first loads, you'll also need to use some javascript to set the focus on your SWF.
这是那篇文章中的示例代码:
Here's the sample code from that article:
Javascript:
<script type="text/javascript">
function onFlexInitialized()
{
//alert("onFlexInitialized");
<!-- Force the browser to set flex app with focus -->
document.getElementById("${application}").focus();
}
</script>
ActionScript:
/**
* Constructor.
*/
public function AppController()
{
FlexGlobals.topLevelApplication.addEventListener(FlexEvent.APPLICATION_COMPLETE, onAppComplete); // Flex 4
//Application.application.addEventListener(FlexEvent.APPLICATION_COMPLETE, onAppComplete); // Flex 3
}
/**
* Handles the application complete event.
*/
protected function onAppComplete(e:FlexEvent):void
{
FlexGlobals.topLevelApplication.removeEventListener(FlexEvent.APPLICATION_COMPLETE, onAppComplete); // Flex 4
//Application.application.removeEventListener(FlexEvent.APPLICATION_COMPLETE, onAppComplete); // Flex 3
if(ExternalInterface.available)
{
ExternalInterface.call("onFlexInitialized");
}
}
这篇关于如何将光标放在 Flex3 中的文本输入中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文