summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authormichaelvogt <michael@vaadin.com>2013-05-17 12:04:33 +0300
committerVaadin Code Review <review@vaadin.com>2013-05-17 09:23:27 +0000
commitfa0c9f5789d6c2f93fe17329d4cd56d2b232a89a (patch)
treea546a68188dd903ae6e1c31de8c03190feda546b /client
parentf1130fab63088a3830deff0ae348e99eedaf9c73 (diff)
downloadvaadin-framework-fa0c9f5789d6c2f93fe17329d4cd56d2b232a89a.tar.gz
vaadin-framework-fa0c9f5789d6c2f93fe17329d4cd56d2b232a89a.zip
Allow to close a context menu with ESC key (#11869)
Change-Id: I4d19b6a385770204bb732893534efb6b62dea19a
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/ui/VContextMenu.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/client/src/com/vaadin/client/ui/VContextMenu.java b/client/src/com/vaadin/client/ui/VContextMenu.java
index a89854e1c8..02ee5b07c5 100644
--- a/client/src/com/vaadin/client/ui/VContextMenu.java
+++ b/client/src/com/vaadin/client/ui/VContextMenu.java
@@ -29,10 +29,13 @@ import com.google.gwt.event.dom.client.HasBlurHandlers;
import com.google.gwt.event.dom.client.HasFocusHandlers;
import com.google.gwt.event.dom.client.HasKeyDownHandlers;
import com.google.gwt.event.dom.client.HasKeyPressHandlers;
+import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyDownEvent;
import com.google.gwt.event.dom.client.KeyDownHandler;
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.event.dom.client.KeyPressHandler;
+import com.google.gwt.event.dom.client.KeyUpEvent;
+import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.event.dom.client.LoadEvent;
import com.google.gwt.event.dom.client.LoadHandler;
import com.google.gwt.event.logical.shared.CloseEvent;
@@ -193,10 +196,11 @@ public class VContextMenu extends VOverlay implements SubPartAware {
*/
class CMenuBar extends MenuBar implements HasFocusHandlers,
HasBlurHandlers, HasKeyDownHandlers, HasKeyPressHandlers,
- Focusable, LoadHandler {
+ Focusable, LoadHandler, KeyUpHandler {
public CMenuBar() {
super(true);
addDomHandler(this, LoadEvent.getType());
+ addDomHandler(this, KeyUpEvent.getType());
}
@Override
@@ -265,6 +269,13 @@ public class VContextMenu extends VOverlay implements SubPartAware {
delayedImageLoadExecutioner.trigger();
}
+ @Override
+ public void onKeyUp(KeyUpEvent event) {
+ // Allow to close context menu with ESC
+ if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
+ hide();
+ }
+ }
}
@Override