Flex / AIR, how to set focus on a UI Control, Butt

2019-05-11 23:25发布

问题:

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.



标签: flex air focus