diff options
Diffstat (limited to 'src/com/vaadin/ui/MenuBar.java')
-rw-r--r-- | src/com/vaadin/ui/MenuBar.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/com/vaadin/ui/MenuBar.java b/src/com/vaadin/ui/MenuBar.java index b7da82675e..d629e912c9 100644 --- a/src/com/vaadin/ui/MenuBar.java +++ b/src/com/vaadin/ui/MenuBar.java @@ -49,6 +49,8 @@ public class MenuBar extends AbstractComponent { private MenuItem moreItem; + private boolean openRootOnHover; + /** Paint (serialise) the component for the client. */ @Override public void paintContent(PaintTarget target) throws PaintException { @@ -56,6 +58,8 @@ public class MenuBar extends AbstractComponent { // Superclass writes any common attributes in the paint target. super.paintContent(target); + target.addAttribute(VMenuBar.OPEN_ROOT_MENU_ON_HOWER, openRootOnHover); + target.startTag("options"); if (submenuIcon != null) { @@ -364,6 +368,31 @@ public class MenuBar extends AbstractComponent { public MenuItem getMoreMenuItem() { return moreItem; } + + /** + * Using this method menubar can be put into a special mode where the root + * level menu opens without clicking on the menu. In this mode the menu also + * closes itself if the mouse is moved out of the opened menu. + * + * @param b + */ + public void setOpenRootOnHover(boolean b) { + if(b != openRootOnHover) { + openRootOnHover = b; + requestRepaint(); + } + } + + /** + * Detects whether the menubar is in a mode where root menus are + * automatically opened when the mouse cursor is moved over the menubar. + * Normally root menu opens only by clicking on the menu. + * + * @return true if the root menus open without click + */ + public boolean isOpenRootOnHover() { + return openRootOnHover; + } /** * This interface contains the layer for menu commands of the |