From 87b6027c6dd284d57c3988fe1e5a8fb600fd33bb Mon Sep 17 00:00:00 2001 From: Denis Anisimov Date: Wed, 26 Mar 2014 22:37:53 +0200 Subject: Trigger action/submenu on SPACE key along with ENTER (#12525). Change-Id: I1548cc90e133f90c94fc33c50fb06a8aff353826 --- client/src/com/vaadin/client/ui/VMenuBar.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'client') 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,12 +1228,28 @@ 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(); -- cgit v1.2.3