Hi all,
I have a Window class and my normal UI class. In the UI class I have a button which opens a window. Now I want to add shortcuts. ENTER for ButtonClick and DELETE to close the Window. This works so far but I need to click the window with my mouse before the DELTE button works. I tried to solve this problem by adding FocusShortcuts and it works great for the button but it doesn’t work for the window. So how can I change the focus from the button to the window with a shortcut?
My UI class code:
[code]
protected void init(VaadinRequest vaadinRequest) {
final VerticalLayout layout = new VerticalLayout();
Button button = new Button("Orderbuch öffnen");
button.addClickListener(new ClickListener() {
public void buttonClick(Button.ClickEvent event) {
Fenster sub = new Fenster();
// Add it to the root component
UI.getCurrent().addWindow(sub);
}
});
// Shortcut to click the button
button.addShortcutListener(new AbstractField.FocusShortcut(button, KeyCode.B));
button.setClickShortcut(KeyCode.ENTER);
layout.addComponents(button);
layout.setMargin(true);
layout.setSpacing(true);
setContent(layout);
}
[/code]My window class code:
public class Fenster extends Window {
public Fenster() {
// Shortcut to close window
addShortcutListener(new AbstractField.FocusShortcut(this, KeyCode.F));
addCloseShortcut(KeyCode.DELETE);
content.setMargin(true);
setContent(content);
}
}