ClickShortcut not working in 6.6.0.pre1


I’m using Vaadin 6.6.0.pre1 and have the following components:

public class Navigation extends CustomLayout {

private TextField username;
private PasswordField password;

	// Username
	username = new TextField("User:");
	addComponent(username, "loginUsername");

	// Password
	password = new PasswordField("Password:");
	addComponent(password, "loginPassword");

	// Login button
	loginButton = new Button("Login");
	// FIXME [Mike N]
: This should bind ENTER to the login button, but doesn't work.
	// 			      A user should be able to type their username/password and then
	//			      hit enter to login...
	loginButton.addListener(new Button.ClickListener() {

		public void buttonClick(ClickEvent event) {
			... login code ...
	addComponent(loginButton, "loginButton");


From my understanding, pressing ENTER in either the username or password field should execute the login code.

Any thoughts?



I just tried with svn version and it worked fine for me. If you have a full example and details on what kind of environment you are using (browser, os), I can investigate this further.


Thanks Matti,

I found the problem, but I’m quite embarrassed to mention the cause… :-). There were 2 almost identical classes, one of which was used and one that wasn’t. I added the code in the one that wasn’t used :-).
I wish there was an Eclipse or Maven plugin that scans the code base for unused classes and notifies me about it…

On a different note, I read that the ClickShortcut is per window, which actually leads to some confusion in my eyes. We’ve got a header with username / password fields and a login button. In the same window, below the header, we have other forms. If a user enters data in one of these forms and hits ENTER, the application automatically tries to log the user in. That is when I set the ClickShortcut of the login button to ENTER.

According to the docs there isn’t a way to do that, but do you have any suggestion on how I could implement something that lets the user enter a username and password, then hit ENTER while the password field has the focus and this automatically logs them in? However, if the user enters data into a different form and hits ENTER, I do not want to trigger the login functionality.



I believe you can e.g.
restrict shortcut scope to a Panel