Focus and Tab Order

Is there a way to re-order or reassign the Elements-Tab Order in a window?
As example, with the controls at the image, I want first the username, then password, then button, so at the start the Username will have the Focus, then if the user press TAB it will go to Password and then to the Button.


I've done a quick test òn 8.1.31 with four text fields and a button. Tab order seems to be left to right, top to bottom but with some leeway given to misalignment in the vertical direction. If I set up

[Text0    ]     [Text1   ]

[Text2    ]     [Text3   ]

    [  Button  ]

Default tab sequence is 0, 1, 2, 3, button.
If I raise Text3 a little higher than Text2 the sequence remains unchanged.
If I raise it about half its height above Text2 then the sequence changes to 0, 1, 3, 2, button.

What problem are you seeing?

1 Like

Careful use of grouping is occasionally necessary to manipulate tab ordering in Vision, but generally speaking the rules are as Transistor deduced.

You are technically able to customize things to great depth by going into Java Swing's internals. I wouldn't recommend it, but for anyone sufficiently motivated, a great starting point is the official Swing tutorial on the focus system:

1 Like

What I was trying to find is a way to "reorder" the tabs index (order), so as in my example I have first the BUTTON, what if I want to move it at the end of the tab-focus order...?
I thought there will be an easy way as in visual studio where we have an TabIndex number.

You want it to be obvious to the user and obey standard expected behavior. If button is the first in the tab order then it shoud be on top.

I too used to do some work with Visual Basic. Actually not having to set the tab order is a benefit. It will work logically.

1 Like

Sometimes I find myself needing to explicitly enforce a tab order. It's usually when there is a focusable object such as a table or button that is along side user inputs or in a container with user inputs. The easiest way I've found is to use the focusLost or focusGained event handler to override any potential unexpected behaviors.


# Inside the focus change event handler
if str(event.cause) == 'TRAVERSAL_FORWARD':

	# Get the component that you want to have focus as a result of this event
	nextFocusComponent = # Put the relative path to the component you want to have focus here
	#nextFocusComponent = event.source.parent.getComponent('Text Field 2') #Example

	# Give the desired component focus

Edit: added a clear example of a relative component path in the code comments

Thank you

I had forgot about this:
Features and Ideas: Tab Order for Components

There was already an idea request for this feature which I had at some point voted for, and the ideas page says that it is now planned. I encountered it [again] today when I was browsing the ideas site to see if there was anything I wanted to vote on, and when I saw it, I remembered this post.

1 Like

Note that it's planned for Perspective, where: 1. the underlying focus traversal system is opaque to you and not exposed the way it is in Vision, and 2: where there's already a native tabIndex property on DOM elements we can expose directly or indirectly.