Flex / AIR, how to set focus on a UI Control, Button, etc?
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);
}
Try:
protected function group1_creationCompleteHandler(event:FlexEvent):void
{
callLater(btnBrowse.setFocus);
}
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/
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}"
.
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.
精彩评论