Default button

After searching half the internet I’m still not able to get a default button. Should I code it by hand using key listeners? From my search I had a moment when I though setting a primary button may do the trick. But apparently this is styling only (what I would expect).

loginButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);

What exactly do you expect for a button to be a “default button”?

If you want this the button to have focus, just call button#focus().

I want the form to commit when you press return or enter in any of the textfields. That is what a default button does (https://definedterm.com/default_button).

@Tom, did you get this to work?

No.

AFAIK the theme only affects look, not fuctionality. Havent done this myself, but i seem to remember that you have to do a shortcut key.

Disclaimer: I haven’t tried it, but take a look at:

https://vaadin.com/directory/component/shortcut/overview

Note that a shortcut key is now part of Vaadin (13+), see https://vaadin.com/releases/vaadin-13#shortcuts-api

Thanks @Ronald. I implemented the V13 shortcut-solution yesterday in test. Works like a charm :slight_smile: