]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixes #5535 "Clicking on a menubar show a visible focus"
authorJouni Koivuviita <jouni.koivuviita@itmill.com>
Thu, 19 May 2011 08:55:27 +0000 (08:55 +0000)
committerJouni Koivuviita <jouni.koivuviita@itmill.com>
Thu, 19 May 2011 08:55:27 +0000 (08:55 +0000)
svn changeset:18908/svn branch:6.6

WebContent/VAADIN/themes/base/menubar/menubar.css
src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java

index 1ce42ce65727e93d9ee79b7df8175526a4634d85..d1972ac4ec43610743e3cc5fff0dfea02b777b8a 100644 (file)
@@ -74,6 +74,7 @@
        margin-right: 3px;
 }
 
+.v-menubar:focus,
 .v-menubar-popup:focus,
 .v-menubar-popup .popupContent:focus,
 .v-menubar-popup .popupContent .v-menubar-submenu:focus{
index 650a51c99205e99997d234002df32ccf04feff77..996b719e338c338d2aabb84278b1bee6327438d4 100644 (file)
@@ -154,8 +154,8 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
             // special case that uses another method. Really should fix the
             // Util.setWidthExcludingPaddingAndBorder method but that will
             // probably break additional cases
-            int requestedPixelWidth = Integer.parseInt(width.substring(0,
-                    width.length() - 2));
+            int requestedPixelWidth = Integer.parseInt(width.substring(0, width
+                    .length() - 2));
             int paddingBorder = Util.measureHorizontalPaddingAndBorder(
                     getElement(), 0);
             int w = requestedPixelWidth - paddingBorder;
@@ -229,8 +229,8 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
             itemHTML.append(moreItemText);
 
             moreItem = new CustomMenuItem(itemHTML.toString(), emptyCommand);
-            collapsedRootItems = new VMenuBar(true,
-                    (VMenuBar) client.getPaintable(uidlId));
+            collapsedRootItems = new VMenuBar(true, (VMenuBar) client
+                    .getPaintable(uidlId));
             moreItem.setSubMenu(collapsedRootItems);
             moreItem.addStyleName(CLASSNAME + "-more-menuitem");
         }
@@ -274,10 +274,12 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
                 itemHTML.append("<span class=\"" + CLASSNAME
                         + "-menuitem-caption\">");
                 if (item.hasAttribute("icon")) {
-                    itemHTML.append("<img src=\""
-                            + client.translateVaadinUri(item
-                                    .getStringAttribute("icon"))
-                            + "\" class=\"" + Icon.CLASSNAME + "\" alt=\"\" />");
+                    itemHTML
+                            .append("<img src=\""
+                                    + client.translateVaadinUri(item
+                                            .getStringAttribute("icon"))
+                                    + "\" class=\"" + Icon.CLASSNAME
+                                    + "\" alt=\"\" />");
                 }
                 itemHTML.append(Util.escapeHTML(itemText) + "</span>");
 
@@ -416,8 +418,8 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
         if (items.contains(item)) {
             int index = items.indexOf(item);
 
-            DOM.removeChild(getContainerElement(),
-                    DOM.getChild(getContainerElement(), index));
+            DOM.removeChild(getContainerElement(), DOM.getChild(
+                    getContainerElement(), index));
             items.remove(index);
         }
     }
@@ -670,7 +672,8 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
         popup.show();
 
         if (left + popup.getOffsetWidth() >= RootPanel.getBodyElement()
-                .getOffsetWidth() - shadowSpace) {
+                .getOffsetWidth()
+                - shadowSpace) {
             if (subMenu) {
                 left = item.getParentMenu().getAbsoluteLeft()
                         - popup.getOffsetWidth() - shadowSpace;
@@ -698,8 +701,8 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
                     }
 
                     if (popup.getElement().getStyle().getProperty("width") == null
-                            || popup.getElement().getStyle()
-                                    .getProperty("width") == "") {
+                            || popup.getElement().getStyle().getProperty(
+                                    "width") == "") {
                         popup.setWidth(popup.getOffsetWidth() + "px");
                     }
                     popup.getElement().getStyle().setProperty("zoom", "1");
@@ -1108,9 +1111,9 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
      * .gwt.event.dom.client.KeyPressEvent)
      */
     public void onKeyPress(KeyPressEvent event) {
-        if (handleNavigation(event.getNativeEvent().getKeyCode(),
-                event.isControlKeyDown() || event.isMetaKeyDown(),
-                event.isShiftKeyDown())) {
+        if (handleNavigation(event.getNativeEvent().getKeyCode(), event
+                .isControlKeyDown()
+                || event.isMetaKeyDown(), event.isShiftKeyDown())) {
             event.preventDefault();
         }
     }
@@ -1123,9 +1126,9 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
      * .event.dom.client.KeyDownEvent)
      */
     public void onKeyDown(KeyDownEvent event) {
-        if (handleNavigation(event.getNativeEvent().getKeyCode(),
-                event.isControlKeyDown() || event.isMetaKeyDown(),
-                event.isShiftKeyDown())) {
+        if (handleNavigation(event.getNativeEvent().getKeyCode(), event
+                .isControlKeyDown()
+                || event.isMetaKeyDown(), event.isShiftKeyDown())) {
             event.preventDefault();
         }
     }
@@ -1432,6 +1435,9 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
      * .dom.client.FocusEvent)
      */
     public void onFocus(FocusEvent event) {
+        // Focus the first element directly, so the keyboard focus becomes
+        // visible
+        setSelected(items.get(0));
     }
 
     private final String SUBPART_PREFIX = "item";