Author: [EMAIL PROTECTED]
Date: Thu Sep 4 13:20:00 2008
New Revision: 3619
Modified:
trunk/user/src/com/google/gwt/user/client/ui/MenuBar.java
trunk/user/src/com/google/gwt/user/client/ui/SuggestBox.java
trunk/user/test/com/google/gwt/user/client/ui/MenuBarTest.java
Log:
MenuBar focuses itself when a MenuItem is selected for any reason so the
user can seamlessly switch between the mouse and keyboard. However, this
means that the SuggestBox loses focus as soon as the first suggestion is
automatically highlighted. This patch makes the focus optional in MenuBar.
Patch by: jlabanca
Review by: ajr
Modified: trunk/user/src/com/google/gwt/user/client/ui/MenuBar.java
==============================================================================
--- trunk/user/src/com/google/gwt/user/client/ui/MenuBar.java (original)
+++ trunk/user/src/com/google/gwt/user/client/ui/MenuBar.java Thu Sep 4
13:20:00 2008
@@ -329,14 +329,14 @@
case Event.ONMOUSEOVER: {
if (item != null) {
- itemOver(item);
+ itemOver(item, true);
}
break;
}
case Event.ONMOUSEOUT: {
if (item != null) {
- itemOver(null);
+ itemOver(null, true);
}
break;
}
@@ -555,7 +555,7 @@
}
}
- void itemOver(MenuItem item) {
+ void itemOver(MenuItem item, boolean focus) {
if (item == null) {
// Don't clear selection if the currently selected item's menu is
showing.
if ((selectedItem != null)
@@ -566,7 +566,9 @@
// Style the item selected when the mouse enters.
selectItem(item);
- focus();
+ if (focus) {
+ focus();
+ }
// If child menus are being shown, or this menu is itself
// a child menu, automatically show an item's child menu
Modified: trunk/user/src/com/google/gwt/user/client/ui/SuggestBox.java
==============================================================================
--- trunk/user/src/com/google/gwt/user/client/ui/SuggestBox.java
(original)
+++ trunk/user/src/com/google/gwt/user/client/ui/SuggestBox.java Thu Sep
4
13:20:00 2008
@@ -173,7 +173,7 @@
public void selectItem(int index) {
List<MenuItem> items = getItems();
if (index > -1 && index < items.size()) {
- itemOver(items.get(index));
+ itemOver(items.get(index), false);
}
}
}
Modified: trunk/user/test/com/google/gwt/user/client/ui/MenuBarTest.java
==============================================================================
--- trunk/user/test/com/google/gwt/user/client/ui/MenuBarTest.java
(original)
+++ trunk/user/test/com/google/gwt/user/client/ui/MenuBarTest.java Thu Sep
4 13:20:00 2008
@@ -114,7 +114,7 @@
RootPanel.get().add(bar);
// Open the item with a submenu
- bar.itemOver(top2);
+ bar.itemOver(top2, true);
// Set the Debug Id
bar.ensureDebugId("myMenu");
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---