在 Flex 中设置焦点 [英] setFocus in Flex

查看:29
本文介绍了在 Flex 中设置焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 flex4 mxml 中使用以下代码,效果很好.

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.

有人可以帮我吗?

推荐答案

问题是在您的应用程序中 TextInput 具有焦点,但在 HTML 页面中您的 Flex 应用程序没有.所以基本上你唯一需要的额外步骤就是让 Flex 应用程序成为焦点.只有一种方法可以实现这一点:通过 JavaScript.您应该在加载应用程序之后执行此操作.

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.

Farrata 的人写了一个很好的例子来说明如何做到这一点,所以我只是想给你指出:http://flexblog.faratasystems.com/2011/12/15/setting-focus-in-flex-components

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

这篇关于在 Flex 中设置焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆