Murgh
Murgh

Reputation: 517

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);
}

Upvotes: 3

Views: 2963

Answers (4)

poortip
poortip

Reputation: 165

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.

Upvotes: 0

Jon
Jon

Reputation: 23

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}".

Upvotes: 0

Jason Towne
Jason Towne

Reputation: 8050

Try:

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

Upvotes: 4

Florian F
Florian F

Reputation: 8875

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/

Upvotes: 0

Related Questions