如何将光标放置在Flex3的文本输入中 [英] how to place cursor in textinput in Flex3
本文介绍了如何将光标放置在Flex3的文本输入中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当用户登录表单到来时如何将光标置于文本输入中。我想光标放在用户名文本输入。 。任何帮助是极大的赞赏!
解决方案
为了配合J_A_X的回答,如果在应用程序首次加载时尝试将焦点置于组件上,还需要使用一些JavaScript将焦点放在你的SWF 上。
以下是该文章的示例代码:
<
函数onFlexInitialized()
{
// alert(onFlexInitialized);
<! - 强制浏览器使用焦点设置flex应用程序 - >
document.getElementById($ {application})。focus();
}
< / script>
ActionScript:
/ **
*构造函数。
* /
public function AppController()
{
FlexGlobals.topLevelApplication.addEventListener(FlexEvent.APPLICATION_COMPLETE,onAppComplete); // Flex 4
//Application.application.addEventListener(FlexEvent.APPLICATION_COMPLETE,onAppComplete); // Flex 3
}
/ **
*处理应用程序完成事件。
* /
保护函数onAppComplete(e:FlexEvent):void
{
FlexGlobals.topLevelApplication.removeEventListener(FlexEvent.APPLICATION_COMPLETE,onAppComplete); // Flex 4
//Application.application.removeEventListener(FlexEvent.APPLICATION_COMPLETE,onAppComplete); // Flex 3
$ b $ if(ExternalInterface.available)
{
ExternalInterface.call(onFlexInitialized);
}
}
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!
解决方案
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:
The Javascript:
<script type="text/javascript">
function onFlexInitialized()
{
//alert("onFlexInitialized");
<!-- Force the browser to set flex app with focus -->
document.getElementById("${application}").focus();
}
</script>
The 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屋!
查看全文