1. Domino UI
  2. Components
  3. Menu bar Pro
Top Basic Background Addons Docs

Menu bar

A component to display a menu bar

See also :

Represents a single entry in a MenuBar . A MenuEntry displays a label (text or HTML) and can optionally host a drop-down Menu for nested items.

Each entry may contain:

  • A text/HTML label
  • A unique key for identification (optional)
  • Zero or more handlers responding to activation/deactivation events

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()));
 

Anatomy

menu-bar-anatomy
  1. Menu bar prfix addons.
  2. Menu bar entries.
  3. Menu bar entry dropdown menu.
  4. Menu bar postfix addons.

Examples

Basic menu bar Classing menu bar with keyboard navigation

Menu bar background Use custom background color

Menu bar addons Add custom prefix/postfix addons

API Docs: MenuBar

Static methods

public static MenuBar create()
Creates a new, empty MenuBar instance.

Returns:

a new MenuBar

API Docs: MenuEntry

Constructors

public void MenuEntry(String label)
Constructs a MenuEntry with a plain text label.

label

the label as plain text

public void MenuEntry(String key, String label)
Constructs a 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)
Constructs a MenuEntry with an HTML label (and no specific key).

label

the label as a SafeHtml

public void MenuEntry(String key, SafeHtml label)
Constructs a MenuEntry with a key and an HTML label.

key

the unique key for this entry

label

the label as a SafeHtml

Static methods

public static MenuEntry create(String text)
Creates a MenuEntry with a plain text label.

text

the label as plain text



Returns:

a new MenuEntry

public static MenuEntry create(String key, String text)
Creates a MenuEntry with a key and a plain text label.

key

a unique key to identify this entry

text

the label as plain text



Returns:

a new MenuEntry

public static MenuEntry create(SafeHtml text)
Creates a MenuEntry with an HTML label.

text

the label as a SafeHtml



Returns:

a new MenuEntry

public static MenuEntry create(String key, SafeHtml text)
Creates a MenuEntry with a key and an HTML label.

key

a unique key to identify this entry

text

the label as a SafeHtml



Returns:

a new MenuEntry

Public methods

public Element getClickableElement()
Check super implementation documentation.

This entry's anchor element is the clickable component that triggers activation.

public boolean isActive()
Checks if this entry is currently active (highlighted) via the dui_active CSS class.

Returns:

true if active

public final MenuEntry activate()
Activates this entry, applying the 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.

Returns:

this MenuEntry , for method chaining

public MenuEntry setLabel(String label)
Updates the displayed label text for this entry.

label

the new label as plain text



Returns:

this MenuEntry , for method chaining

public MenuEntry setLabel(SafeHtml label)
Updates the displayed label HTML for this entry.

label

the new label as SafeHtml



Returns:

this MenuEntry , for method chaining

public MenuEntry withMenu(ChildHandler<MenuEntry, IsMenu<?, ?, ?, ?>> handler)
Applies a ChildHandler to the menu attached to this entry, if any.

handler

a functional interface that receives this entry and its Menu



Returns:

this MenuEntry , for method chaining

public MenuEntry addActivationListener(MenuEntryListener listener)
Registers a listener to be called whenever this entry is activated (becomes highlighted).

listener

the activation listener



Returns:

this MenuEntry , for method chaining

public MenuEntry removeActivationListener(MenuEntryListener listener)
Removes a previously registered activation listener.

listener

the activation listener



Returns:

this MenuEntry , for method chaining

public MenuEntry addDeactivationListener(MenuEntryListener listener)
Registers a listener to be called whenever this entry is deactivated (loses highlight).

listener

the deactivation listener



Returns:

this MenuEntry , for method chaining

public MenuEntry removeDeactivationListener(MenuEntryListener listener)
Removes a previously registered deactivation listener.

listener

the deactivation listener



Returns:

this MenuEntry , for method chaining

public HTMLLIElement element()
Check super implementation documentation.

Returns the root

  • element representing this menu entry.
  • public MenuEntry setKey(String key)
    Sets the unique key for this entry. The key may be used by a parent MenuBar to activate this entry via activateByKey .

    key

    the new key



    Returns:

    this MenuEntry , for method chaining

    public String getKey()


    Returns:

    the key associated with this entry, or null if no key was set

    public boolean equals(Object o)
    Compares two MenuEntry objects for equality, based on their key values.

    o

    another object



    Returns:

    true if both entries have the same key

    public int hashCode()


    Returns:

    a hash code derived from this entry's key

    We are a group of passionate people who love what we do

    Donate & Support Us