I totally agree, thank you :)
-- Edvin
Den 06.05.2011 13:41, skrev Greg Brown:
This is my first day of actual Pivot programming, and I created a login screen
that has some TextInput fields. I want the first field to be focused when the
form opens, so I did it like this:
public class LoginFrame extends Frame implements Bindable {
@BXML TextInput hostname;
public void open(Display display, Window owner) {
super.open(display, owner);
hostname.requestFocus();
}
}
This works, but I'm thinking there must be a smoother way, like setting a
property on the TextInput when I declare it in my BXML maybe?
Nope, you have it right. BXML is for defining the structure of an application.
Requesting focus is a behavior, so that should happen in code.
I understand that I cannot request focus for the component in the
Bindable#initialize() method, since the component isn't actually displaying at
the time of initialization, but maybe there is a way for the framework to sort
this out by looking at a property or something when it is first displayed?
You could implement a custom focus traversal policy and set that on your
window's content component. However, I think that calling requestFocus() in
open() or in response to an open event is probably going to be simpler.
G