Search code examples
javagwt

Is there a way to retrieve the tab order of HTML elements in Java?


Right now we have an element on the page that is not allowing users to tab out of it. The element was created in Java as a GWT component, I don't really know too much about GWT so I can't really describe it further.

Anyways, I know where I need to tell the component to tab to the next element in the tab order, but I don't know what commands to use to do so. Is there a way to retrieve the tab order of HTML elements in Java? If there is, I can just pick the next element in the list and set it to be focussed.


Solution

  • Using GWT com.google.gwt.dom.client.Element you can access and set the tabIndex value of any GWT component (i.e. html element). If you're using a Widget class you can use myWidget.getElement().getTabIndex() and setTabIndex(1).

    In HTML you cannot just pick the next element with the tab out of the box, you can however maintain the tab indexes order in the order you expect.