Flex 中的 setFocus
我在 flex4 mxml 中使用以下代码,效果很好。
<mx:Button label="Set focus to Username"
click="focusManager.setFocus(username);" />
如何在动作脚本中使用相同的内容我的意思是在不使用按钮的情况下创建应用程序的完成事件。
那是我在应用程序中有登录面板,当页面加载时 用户名字段应集中光标在其中。
有人可以帮助我吗?
I'm Using following code in flex4 mxml That works fine.
<mx:Button label="Set focus to Username"
click="focusManager.setFocus(username);" />
How to use the same in Action script I mean creation complete event of an application without using button.
That is I have login panel in application While page loads the
username field should focused having cursor in it.
Can any one help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是,在您的应用程序中,TextInput 具有焦点,但在 HTML 页面中,您的 Flex 应用程序没有焦点。因此基本上您需要的唯一额外步骤就是让 Flex 应用程序获得焦点。只有一种方法可以实现这一点:通过 JavaScript。您应该在应用程序加载后执行此操作。
Farrata 的人写了一个很好的例子来说明如何做到这一点,所以我只想向您指出:http://flexblog.faratasystems.com/2011/12/15/setting-focus-in-flex-components
The issue is that within your application the TextInput has focus, but within the HTML page your Flex application does not. So basically the only extra step you need is to give the Flex app focus. There's only one way to achieve this: through JavaScript. And you should do it after the application was loaded.
The guys at Farrata wrote a very good example on how to do this, so I'm just going to point you there: http://flexblog.faratasystems.com/2011/12/15/setting-focus-in-flex-components