setFocus in Flex

情到浓时终转凉″ 提交于 2019-12-12 03:03:48

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/8643079/setfocus-in-flex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!