blob: dcd19f6b2ab3643aadaa20ca3286af362c1dd513 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
package com.vaadin.tests.components.combobox;
import com.vaadin.event.ShortcutAction.KeyCode;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
/**
* Ticket #12163: when a combo box popup is open in a subwindow, escape should
* only close it and not the window, also on Safari 6.
*/
public class EscapeClosesComboboxNotWindow extends UI {
final Window window = new Window("Window");
@Override
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);
Button button = new Button("Click Me");
button.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
final FormLayout content = new FormLayout();
ComboBox cb = new ComboBox();
cb.addItem("foo");
cb.addItem("bar");
content.addComponent(cb);
window.setContent(content);
window.setCloseShortcut(KeyCode.ESCAPE);
UI.getCurrent().addWindow(window);
}
});
layout.addComponent(button);
}
}
|