]> source.dussan.org Git - vaadin-framework.git/commitdiff
Another fix for #5174
authorJohn Alhroos <john.ahlroos@itmill.com>
Thu, 17 Jun 2010 09:28:00 +0000 (09:28 +0000)
committerJohn Alhroos <john.ahlroos@itmill.com>
Thu, 17 Jun 2010 09:28:00 +0000 (09:28 +0000)
svn changeset:13729/svn branch:6.4

src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java

index 3f25579291f5bcc3e6d18b88fcceb80a297e0731..240194b4bce56932632d5452e98eef78dc7e9080 100644 (file)
@@ -9,8 +9,6 @@ import java.util.List;
 import java.util.Stack;
 
 import com.google.gwt.dom.client.NodeList;
-import com.google.gwt.event.dom.client.BlurEvent;
-import com.google.gwt.event.dom.client.BlurHandler;
 import com.google.gwt.event.dom.client.FocusEvent;
 import com.google.gwt.event.dom.client.FocusHandler;
 import com.google.gwt.event.dom.client.KeyCodes;
@@ -39,7 +37,7 @@ import com.vaadin.terminal.gwt.client.Util;
 
 public class VMenuBar extends SimpleFocusablePanel implements Paintable,
         CloseHandler<PopupPanel>, ContainerResizedListener, KeyPressHandler,
-        KeyDownHandler, BlurHandler, FocusHandler, SubPartAware {
+        KeyDownHandler, FocusHandler, SubPartAware {
 
     /** Set the CSS class name to allow styling. */
     public static final String CLASSNAME = "v-menubar";
@@ -68,7 +66,6 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
     protected CustomMenuItem selected;
 
     private Timer layoutTimer;
-    private Timer blurDelayTimer;
     private Timer focusDelayTimer;
 
     private boolean enabled = true;
@@ -79,7 +76,6 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
 
         // Navigation is only handled by the root bar
         addFocusHandler(this);
-        addBlurHandler(this);
 
         /*
          * Firefox auto-repeat works correctly only if we use a key press
@@ -110,7 +106,7 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
         this.subMenu = subMenu;
 
         sinkEvents(Event.ONCLICK | Event.ONMOUSEOVER | Event.ONMOUSEOUT
-                | Event.ONMOUSEDOWN | Event.ONLOAD);
+                | Event.ONLOAD);
     }
 
     @Override
@@ -290,11 +286,6 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
      *            id of the item that was clicked
      */
     public void onMenuClick(int clickedItemId) {
-        // Cancel the blur event handling, focus was lost to a submenu
-        if (blurDelayTimer != null) {
-            blurDelayTimer.cancel();
-        }
-
         // Cancel the focus event handling since focus was gained by
         // clicking an item.
         if (focusDelayTimer != null) {
@@ -423,12 +414,6 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
         if (targetItem != null) {
             switch (DOM.eventGetType(e)) {
 
-            case Event.ONMOUSEDOWN:
-                if (isEnabled() && targetItem.isEnabled()) {
-                    selected = targetItem;
-                }
-                break;
-
             case Event.ONCLICK:
                 if (isEnabled() && targetItem.isEnabled()) {
                     itemClick(targetItem);
@@ -1030,7 +1015,16 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
      * @return true iff the navigation event was handled
      */
     public boolean handleNavigation(int keycode, boolean ctrl, boolean shift) {
-        if (keycode == KeyCodes.KEY_TAB || ctrl || shift || !isEnabled()) {
+
+        // If tab or shift+tab close menus
+        if (keycode == KeyCodes.KEY_TAB) {
+            setSelected(null);
+            hideChildren();
+            menuVisible = false;
+            return false;
+        }
+
+        if (ctrl || shift || !isEnabled()) {
             // Do not handle tab key, nor ctrl keys
             return false;
         }
@@ -1242,29 +1236,6 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
         return false;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * com.google.gwt.event.dom.client.BlurHandler#onBlur(com.google.gwt.event
-     * .dom.client.BlurEvent)
-     */
-    public void onBlur(BlurEvent event) {
-        /*
-         * Delay the action so a mouse click can cancel the blur event if needed
-         */
-        blurDelayTimer = new Timer() {
-            @Override
-            public void run() {
-                setSelected(null);
-                hideChildren();
-                menuVisible = false;
-            }
-        };
-
-        blurDelayTimer.schedule(100);
-    }
-
     /*
      * (non-Javadoc)
      *