See also :
MenuEntry displays a label (text or HTML) and can optionally host a drop-down Menu for nested items.
Each entry may contain:
When activated, an entry becomes highlighted (via the dui_active CSS class). If it has an attached drop-down menu, that menu opens. Similarly, deactivation closes the menu and removes the highlight.
Example usage:
MenuEntry entry = MenuEntry.create("homeKey", "Home");
entry.addActivationHandler(e -> DomGlobal.console.log("Activated: " + e.getKey()));
public static MenuBar create()
MenuBar instance.
a new MenuBar
public void MenuEntry(String label)
MenuEntry with a plain text label.
label
the label as plain text
public void MenuEntry(String key, String label)
MenuEntry with a key and a plain text label.
key
the unique key for this entry
label
the label as plain text
public void MenuEntry(SafeHtml label)
MenuEntry with an HTML label (and no specific key).
label
the label as a SafeHtml
public void MenuEntry(String key, SafeHtml label)
MenuEntry with a key and an HTML label.
key
the unique key for this entry
label
the label as a SafeHtml
public static MenuEntry create(String text)
public static MenuEntry create(String key, String text)
key
a unique key to identify this entry
text
the label as plain text
a new MenuEntry
public static MenuEntry create(SafeHtml text)
public Element getClickableElement()
This entry's anchor element is the clickable component that triggers activation.
public boolean isActive()
dui_active CSS class.
true if active
public final MenuEntry activate()
dui_active class, opening its drop-down menu (if present), and focusing its anchor element. Also notifies the parent MenuBar that this entry is now active.
this MenuEntry , for method chaining
public MenuEntry setLabel(String label)
label
the new label as plain text
this MenuEntry , for method chaining
public MenuEntry setLabel(SafeHtml label)
label
the new label as SafeHtml
this MenuEntry , for method chaining
public MenuEntry withMenu(ChildHandler<MenuEntry, IsMenu<?, ?, ?, ?>> handler)
handler
a functional interface that receives this entry and its Menu
this MenuEntry , for method chaining
public MenuEntry addActivationListener(MenuEntryListener listener)
listener
the activation listener
this MenuEntry , for method chaining
public MenuEntry removeActivationListener(MenuEntryListener listener)
listener
the activation listener
this MenuEntry , for method chaining
public MenuEntry addDeactivationListener(MenuEntryListener listener)
listener
the deactivation listener
this MenuEntry , for method chaining
public MenuEntry removeDeactivationListener(MenuEntryListener listener)
listener
the deactivation listener
this MenuEntry , for method chaining
public HTMLLIElement element()
Returns the root
public MenuEntry setKey(String key)
key
the new key
this MenuEntry , for method chaining
public String getKey()
the key associated with this entry, or null if no key was set
public boolean equals(Object o)
MenuEntry objects for equality, based on their key values.
o
another object
true if both entries have the same key
public int hashCode()
a hash code derived from this entry's key