This content has been marked as final. Show 7 replies
Unfortunately there is no high level functionality (like assigning a tab order ids to controls in fxml or having a having focusmodel implementation) that I know of (consider raising a jira request http://javafx-jira.kenai.com).
There is a focusproperty on node, so you can add listeners to that property for the controls you are interested in and set the focus to the next control that you want the user to be able to navigate to (via the control.requestFocus() method) - not a great solution I know, so I'd be interested if anybody has a better one.
Actually, the tab order seems to track the order of the elements in the FXML. This is not necessarily the order perceived by the user, as the FXML can give a position for the first element on its list that puts it graphically below the second element, and so forth.
If you're using Scene Builder you can just drag-and-drop elements in the Hierarchy view to change their order - it has no effect on their screen locations.
I don't use the Scene Builder, so I don't understand precisely how I could achieve without layout modifications.
For example, when I've got a HBox with three buttons, I know that the focus will go from left to right, so when I want it from right to left I reach a limit, I need to change my layout, use a GridPane or so that allows me to write nodes in the right order in the FXML file. Or am I missing some point?
For example, when I've got a HBox with three buttons, I know that the focus will go from left to right, so when I want it from right to left I reach a limit, I need to change my layout, use a GridPane or so that allows me to write nodes in the right order in the FXML file. Or am I missing some point?Nope, you understand the point exactly.
There is a FocusModel which may help in such situations, but there is no documentation on how it is intended to be used:
I believe (and I don't really know) the intent of the FocusModel is for internal use within custom controls, so you could define a custom control for your HBox + buttons and utilize a FocusModel internally to the control manage the focus. It is a rather heavy handed solution though and the APIs for defining custom controls aren't documented anyway.
At this point, I'd go back to the original suggestion in this thread of raising a jira feature request against the runtime at:
In the jira request link back to this thread and include a description of your use case.
Probably it wouldn't be implemented until post JavaFX 8, which is unlikely to help you, but may help others in the future.