aboutsummaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorDenis Anisimov <denis@vaadin.com>2014-03-26 22:37:53 +0200
committerVaadin Code Review <review@vaadin.com>2014-04-02 05:30:16 +0000
commit87b6027c6dd284d57c3988fe1e5a8fb600fd33bb (patch)
tree338d76c25d6b2b0ecc7d7ff525896bf3881d7d90 /client
parentcb4d7aefb6aee18c3ca4a144a545a1e179415f53 (diff)
downloadvaadin-framework-87b6027c6dd284d57c3988fe1e5a8fb600fd33bb.tar.gz
vaadin-framework-87b6027c6dd284d57c3988fe1e5a8fb600fd33bb.zip
Trigger action/submenu on SPACE key along with ENTER (#12525).
Change-Id: I1548cc90e133f90c94fc33c50fb06a8aff353826
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/ui/VMenuBar.java18
1 files changed, 17 insertions, 1 deletions
diff --git a/client/src/com/vaadin/client/ui/VMenuBar.java b/client/src/com/vaadin/client/ui/VMenuBar.java
index 34196ff363..a2715fd786 100644
--- a/client/src/com/vaadin/client/ui/VMenuBar.java
+++ b/client/src/com/vaadin/client/ui/VMenuBar.java
@@ -1228,13 +1228,29 @@ public class VMenuBar extends SimpleFocusablePanel implements
* Get the key that selects a menu item. By default it is the Enter key but
* by overriding this you can change the key to whatever you want.
*
+ * @deprecated use {@link #isNavigationSelectKey(int)} instead
* @return
*/
+ @Deprecated
protected int getNavigationSelectKey() {
return KeyCodes.KEY_ENTER;
}
/**
+ * Checks whether key code selects a menu item. By default it is the Enter
+ * and Space keys but by overriding this you can change the keys to whatever
+ * you want.
+ *
+ * @since 7.2
+ * @param keycode
+ * @return true if key selects menu item
+ */
+ protected boolean isNavigationSelectKey(int keycode) {
+ return keycode == getNavigationSelectKey()
+ || keycode == KeyCodes.KEY_SPACE;
+ }
+
+ /**
* Get the key that closes the menu. By default it is the escape key but by
* overriding this yoy can change the key to whatever you want.
*
@@ -1432,7 +1448,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
hideChildren();
menuVisible = false;
- } else if (keycode == getNavigationSelectKey()) {
+ } else if (isNavigationSelectKey(keycode)) {
if (getSelected() == null) {
// If nothing is selected then select the first item
selectFirstItem();