Flex / AIR, how to set focus on a UI Control, Button, etc?

南楼画角 提交于 2020-01-02 08:19:48

问题


So, I'm trying to set focus on a specific button when the app launches (or later based on certain events), so that the user can simply hit return to press the button. None of the following approaches work however.

protected function group1_creationCompleteHandler(event:FlexEvent):void
{
//btnBrowse.setFocus();
focusManager.setFocus(btnBrowse);
}


回答1:


Try:

protected function group1_creationCompleteHandler(event:FlexEvent):void
{
  callLater(btnBrowse.setFocus);
}



回答2:


Flex doesn't have focus on application startup, js does. You need to find some tricks on google to pass the focus from the browser to flash.

Here is the first one I found : http://edsyrett.wordpress.com/2008/08/15/focus-issues-in-flex/




回答3:


To hit the return button and have it automatically execute the Click event, in the panel, canvas, etc where the user is in, set defaultButton="{buttonid}".




回答4:


Not sure if the answer is still relevant, but try adding both.

Make the button as default for the application, and add focus to it on the creation complete event.



来源:https://stackoverflow.com/questions/4936058/flex-air-how-to-set-focus-on-a-ui-control-button-etc

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