}
public void setSelected(boolean selected) {
- if (selected && !isSeparator) {
+ if (selected && isSelectable()) {
addStyleDependentName("selected");
// needed for IE6 to have a single style name to match for an
// element
return menubar;
}
+ /**
+ * Checks if the item can be selected.
+ *
+ * @return true if it is possible to select this item, false otherwise
+ */
+ public boolean isSelectable() {
+ return !isSeparator() && isEnabled();
+ }
+
}
/**
if (getSelected() == null) {
// If nothing is selected then select the last item
setSelected(items.get(items.size() - 1));
- if (getSelected().isSeparator() || !getSelected().isEnabled()) {
+ if (!getSelected().isSelectable()) {
handleNavigation(keycode, ctrl, shift);
}
} else if (visibleChildMenu == null && getParentMenu() == null) {
- // If this is the root menu then move to the right
+ // If this is the root menu then move to the left
int idx = items.indexOf(getSelected());
if (idx > 0) {
setSelected(items.get(idx - 1));
setSelected(items.get(items.size() - 1));
}
- if (getSelected().isSeparator() || !getSelected().isEnabled()) {
+ if (!getSelected().isSelectable()) {
handleNavigation(keycode, ctrl, shift);
}
} else if (visibleChildMenu != null) {
visibleChildMenu.handleNavigation(keycode, ctrl, shift);
} else if (getParentMenu().getParentMenu() == null) {
-
- // Get the root menu
+ // Inside a sub menu, whose parent is a root menu item
VMenuBar root = getParentMenu();
root.getSelected().getSubMenu().setSelected(null);
if (getSelected() == null) {
// If nothing is selected then select the first item
setSelected(items.get(0));
- if (getSelected().isSeparator() || !getSelected().isEnabled()) {
+ if (!getSelected().isSelectable()) {
handleNavigation(keycode, ctrl, shift);
}
} else if (visibleChildMenu == null && getParentMenu() == null) {
setSelected(items.get(0));
}
- if (getSelected().isSeparator() || !getSelected().isEnabled()) {
+ if (!getSelected().isSelectable()) {
handleNavigation(keycode, ctrl, shift);
}
} else if (visibleChildMenu == null
if (getSelected() == null) {
// If nothing is selected then select the last item
setSelected(items.get(items.size() - 1));
- if (getSelected().isSeparator() || !getSelected().isEnabled()) {
+ if (!getSelected().isSelectable()) {
handleNavigation(keycode, ctrl, shift);
}
} else if (visibleChildMenu != null) {
setSelected(items.get(items.size() - 1));
}
- if (getSelected().isSeparator() || !getSelected().isEnabled()) {
+ if (!getSelected().isSelectable()) {
handleNavigation(keycode, ctrl, shift);
}
}
if (getSelected() == null) {
// If nothing is selected then select the first item
setSelected(items.get(0));
- if (getSelected().isSeparator() || !getSelected().isEnabled()) {
+ if (!getSelected().isSelectable()) {
handleNavigation(keycode, ctrl, shift);
}
} else if (visibleChildMenu == null && getParentMenu() == null) {
setSelected(items.get(0));
}
- if (getSelected().isSeparator() || !getSelected().isEnabled()) {
+ if (!getSelected().isSelectable()) {
handleNavigation(keycode, ctrl, shift);
}
}