summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WebContent/VAADIN/themes/base/menubar/menubar.css1
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java44
2 files changed, 26 insertions, 19 deletions
diff --git a/WebContent/VAADIN/themes/base/menubar/menubar.css b/WebContent/VAADIN/themes/base/menubar/menubar.css
index 1ce42ce657..d1972ac4ec 100644
--- a/WebContent/VAADIN/themes/base/menubar/menubar.css
+++ b/WebContent/VAADIN/themes/base/menubar/menubar.css
@@ -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{
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
index 650a51c992..996b719e33 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
@@ -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";