Class MenuItem
An item contained inside a Menu element.
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
public class MenuItem : BaseVisualElement, IEventHandler, IVisualElementScheduler, IExperimentalFeatures, ITransitionAnimations, ITransform, IResolvedStyle, IContextOverrideElement, IAdditionalDataHolder, INotifyValueChanged<bool>, IPressable
Constructors
MenuItem()
Default constructor.
Declaration
public MenuItem()
Fields
activeUssClassname
The MenuItem active styling class.
Declaration
public const string activeUssClassname = "appui-menuitem--active"
Field Value
Type | Description |
---|---|
string |
checkmarkUssClassName
The MenuItem checkmark styling class.
Declaration
public const string checkmarkUssClassName = "appui-menuitem__checkmark"
Field Value
Type | Description |
---|---|
string |
iconUssClassName
The MenuItem icon styling class.
Declaration
public const string iconUssClassName = "appui-menuitem__icon"
Field Value
Type | Description |
---|---|
string |
labelUssClassName
The MenuItem label styling class.
Declaration
public const string labelUssClassName = "appui-menuitem__label"
Field Value
Type | Description |
---|---|
string |
selectableUssClassname
The MenuItem selectable mode styling class.
Declaration
public const string selectableUssClassname = "appui-menuitem--selectable"
Field Value
Type | Description |
---|---|
string |
shortcutUssClassName
The MenuItem shortcut styling class.
Declaration
public const string shortcutUssClassName = "appui-menuitem__shortcut"
Field Value
Type | Description |
---|---|
string |
subMenuIconUssClassname
The MenuItem submenu icon styling class.
Declaration
public const string subMenuIconUssClassname = "appui-menuitem__submenu-icon"
Field Value
Type | Description |
---|---|
string |
subMenuItemUssClassname
The MenuItem submenu mode styling class.
Declaration
public const string subMenuItemUssClassname = "appui-menuitem--submenu"
Field Value
Type | Description |
---|---|
string |
ussClassName
The MenuItem main styling class.
Declaration
public const string ussClassName = "appui-menuitem"
Field Value
Type | Description |
---|---|
string |
Properties
active
Enable or disable the active mode of the item.
Declaration
public bool active { get; set; }
Property Value
Type | Description |
---|---|
bool |
clickable
Clickable Manipulator for this MenuItem.
Declaration
public Pressable clickable { get; set; }
Property Value
Type | Description |
---|---|
Pressable |
contentContainer
The content container of the MenuItem.
Declaration
public override VisualElement contentContainer { get; }
Property Value
Type | Description |
---|---|
VisualElement |
Overrides
hasSubMenu
Whether the item has a sub menu.
Declaration
public bool hasSubMenu { get; }
Property Value
Type | Description |
---|---|
bool |
icon
The icon to display next to the label.
Declaration
public string icon { get; set; }
Property Value
Type | Description |
---|---|
string |
label
The label text value.
Declaration
public string label { get; set; }
Property Value
Type | Description |
---|---|
string |
selectable
Enable or disable the selectable mode of the item.
A selectable item is an item with a small checkmark as leading UI element.
Declaration
public bool selectable { get; set; }
Property Value
Type | Description |
---|---|
bool |
shortcut
The shortcut text value.
Declaration
public string shortcut { get; set; }
Property Value
Type | Description |
---|---|
string |
subMenu
Sub Menu linked to this item.
An item with a submenu mode enabled has a small caret as trailing UI element which defines that a sub menu will appear if you trigger the item's action.
Declaration
public Menu subMenu { get; set; }
Property Value
Type | Description |
---|---|
Menu |
value
The selected state of the item.
Declaration
public bool value { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
You should set the item as selectable first to see any result.
Methods
SetValueWithoutNotify(bool)
Set the selected state of this item.
See value and selectable properties for more info.
Declaration
public void SetValueWithoutNotify(bool newValue)
Parameters
Type | Name | Description |
---|---|---|
bool | newValue | The new selected state. |
Events
subMenuOpened
The event raised when the item's submenu is opened.
Declaration
public event Action subMenuOpened
Event Type
Type | Description |
---|---|
Action |