Skip to main content
Participant
November 10, 2011
Answered

Programmatic tab through the components on the screen

  • November 10, 2011
  • 1 reply
  • 76841 views

Hello,

I've a requirement to tab through all the components that are in the tab order in a screen. But it has to be done programmatically on press of a button, if a user presses tab key on the keyboard, tabbing follows an order as set on the tabIndex property of each and every component. can this be mocked by a button press? if so how can I it be done?

This topic has been closed for replies.
Correct answer Alex J Harui

I think you will need to dispatch KEY_FOCUS_CHANGE event.

1 reply

Participant
November 10, 2011

If I understand the question correctly, you want to mock the behaviour of the "TAB" key when your application is opened by the "click" event of a button component.

The application should cycle the focus between spark components on the KeyboardEvent with the Keyboard.TAB for the keyCode property.

I believe you can simulate this by manually constructing this KeyboardEvent in the handler function of your button's click event. The event should propagate and trigger the default behavior of the TAB key.

Alex J HaruiCorrect answer
Adobe Employee
November 10, 2011

I think you will need to dispatch KEY_FOCUS_CHANGE event.

Adobe Employee
November 10, 2011

On which component should I be dispatching the KEY_FOCUS_CHANGE event on? the application or the component on which the focus was active?


The component that currently has focus. Try:

focusManager.getFocus().dispatchEvent(new FocusEvent(FocusEvent.KEY_FOCUS_CHANGE, ....

FWIW, focusManager has a method called getNextFocusManagerComponent(), in case you want to know where focus is going to go next.