summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/ui/MenuBar.java
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2011-04-13 11:20:07 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2011-04-13 11:20:07 +0000
commit16aae528a8986c2c25b60341a77366a68f5aaa2f (patch)
tree89d6710fa931e9aa38422da18a10f1e41c966547 /src/com/vaadin/ui/MenuBar.java
parentf63738e10ada9af16cd32b99a477b6398f665432 (diff)
downloadvaadin-framework-16aae528a8986c2c25b60341a77366a68f5aaa2f.tar.gz
vaadin-framework-16aae528a8986c2c25b60341a77366a68f5aaa2f.zip
#6440: mode to open root nodes by mouse over only
svn changeset:18266/svn branch:6.6
Diffstat (limited to 'src/com/vaadin/ui/MenuBar.java')
-rw-r--r--src/com/vaadin/ui/MenuBar.java29
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