reading this page of the Book of Vaadin:
You can also specify the shortcut by a shorthand notation, where the shortcut key is indicated with an ampersand (&).
// A field with Alt+A bound to it, using shorthand notation
TextField address = new TextField("Address (Alt+A)");
new AbstractField.FocusShortcut(address, "&Address"));
This is especially useful for internationalization, so that you can determine the shortcut key from the localized string.
If I add this
address textfield object to my layout and then I press Alt+A the field is focused.
But how does Vaadin knows that "&Address" is ALT+A??? Does it parses the string internally or compares it with something?
What is this "&Address"
shorthand notation for keyboard shortcuts? Are there also other shorthand notations?
Best How To :
Insert one or more modifier characters before the character to use as keycode. E.g "&Save" will make a shortcut responding to ALT-S, "E^xit" will respond to CTRL-X. Multiple modifiers can be used, e.g "&^Delete" will respond to CTRL-ALT-D (the order of the modifier characters is not important).
The modifier characters will be removed from the caption. The modifier character is be escaped by itself: two consecutive characters are turned into the original character w/o the special meaning. E.g "Save&&&close" will respond to ALT-C, and the caption will say "Save&close".
There are three modifier characters:
& (alt), and
_ (shift). Internally, Vaadin uses regular expressions to parse the shorthand caption, match the modifier characters and build the keyboard shortcuts. You can look at the code here.