Interface UserMenuItem
- All Superinterfaces:
com.vaadin.flow.component.HasElement,HasSubParts,com.vaadin.flow.component.HasTheme,com.vaadin.flow.component.shared.HasThemeVariant<UserMenuItemVariant>,Serializable
- All Known Subinterfaces:
ActionUserMenuItem,ComponentUserMenuItem,TextUserMenuItem,ViewUserMenuItem
- All Known Implementing Classes:
JmixUserMenu.AbstractTextUserMenuItem,JmixUserMenu.AbstractUserMenuItem,JmixUserMenu.ActionUserMenuItemImpl,JmixUserMenu.ComponentUserMenuItemImpl,JmixUserMenu.TextUserMenuItemImpl,JmixUserMenuItemsDelegate.SeparatorUserMenuItem,UserMenu.ViewUserMenuItemImpl
public interface UserMenuItem
extends com.vaadin.flow.component.shared.HasThemeVariant<UserMenuItemVariant>, HasSubParts
Represents an item that can be included in a user menu component.
Defines the common behavior for items such as visibility, enabling/disabling,
and handling click events.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceThis interface provides functionality for adding click listeners to user menu items.static interfaceRepresents an interface for menu items that can optionally have a submenu. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.RegistrationaddPropertyChangeListener(Consumer<PropertyChangeEvent> listener) Adds a listener to be notified about changes in the properties of the action.getId()Returns the unique identifier of the user menu item.booleanReturns whether this item toggles a checkmark icon when clicked.booleanReturns the checked state of this item.booleanChecks whether the user menu item is currently enabled.booleanChecks whether the user menu item is currently visible.voidsetCheckable(boolean checkable) Sets the checkable state of this menu item.voidsetChecked(boolean checked) Sets the checked state of this item.voidsetEnabled(boolean enabled) Enables or disables the user menu item.voidsetVisible(boolean visible) Sets the visibility of the user menu item.Methods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface io.jmix.flowui.kit.component.HasSubParts
getSubPartMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, removeThemeVariants
-
Field Details
-
PROP_ENABLED
- See Also:
-
PROP_VISIBLE
- See Also:
-
PROP_CHECKABLE
- See Also:
-
PROP_CHECKED
- See Also:
-
-
Method Details
-
getId
String getId()Returns the unique identifier of the user menu item.- Returns:
- the unique identifier of the menu item
-
isVisible
boolean isVisible()Checks whether the user menu item is currently visible. A visible item is displayed in the dropdown and can interact with users, whereas an invisible item is hidden and cannot be interacted with.- Returns:
- true if the item is visible, false otherwise
-
setVisible
void setVisible(boolean visible) Sets the visibility of the user menu item. A visible item is rendered and can interact with users, while an invisible item is not displayed and cannot be interacted with.- Parameters:
visible- if true, the item will be visible; otherwise, it will be hidden
-
isEnabled
boolean isEnabled()Checks whether the user menu item is currently enabled. An enabled item can be interacted with, whereas a disabled item cannot.- Returns:
trueif the item is enabled,falseotherwise
-
setEnabled
void setEnabled(boolean enabled) Enables or disables the user menu item. When the item is disabled, it cannot be interacted with.- Parameters:
enabled- iftrue, the item will be enabled; otherwise, it will be disabled
-
isCheckable
boolean isCheckable()Returns whether this item toggles a checkmark icon when clicked.- Returns:
- the checkable state of the item
- See Also:
-
setCheckable
void setCheckable(boolean checkable) Sets the checkable state of this menu item. A checkable item toggles a checkmark icon when clicked. Changes in the checked state can be handled in the item's click handler withisChecked().Setting a checked item un-checkable also makes it un-checked.
- Parameters:
checkable-trueto enable toggling the checked-state of this menu item by clicking,falseto disable it.- Throws:
IllegalStateException- if setting a parent item checkable
-
isChecked
boolean isChecked()Returns the checked state of this item. The item can be checked and un-checked withsetChecked(boolean)or by clicking it when it is checkable. A checked item displays a checkmark icon inside it.- Returns:
trueif the item is checked,falseotherwise- See Also:
-
setChecked
void setChecked(boolean checked) Sets the checked state of this item. A checked item displays a checkmark icon next to it. The checked state is also toggled by clicking the item.Note that the item needs to be explicitly set as checkable via
setCheckable(boolean)in order to check it.- Parameters:
checked-trueto check this item,falseto un-check it- Throws:
IllegalStateException- if trying to check the item when it's checkable
-
addPropertyChangeListener
com.vaadin.flow.shared.Registration addPropertyChangeListener(Consumer<PropertyChangeEvent> listener) Adds a listener to be notified about changes in the properties of the action.- Parameters:
listener- listener to add- Returns:
- a registration object for removing an event listener
-