Class DropdownMenuAction
A menu action item.
Namespace: UnityEngine.UIElements
Syntax
public class DropdownMenuAction : DropdownMenuItem
Constructors
DropdownMenuAction(String, Action<DropdownMenuAction>, Func<DropdownMenuAction, DropdownMenuAction.Status>, Object)
Constructor.
Declaration
public DropdownMenuAction(string actionName, Action<DropdownMenuAction> actionCallback, Func<DropdownMenuAction, DropdownMenuAction.Status> actionStatusCallback, object userData = null)
Parameters
Type | Name | Description |
---|---|---|
String | actionName | The path and name of the menu item. Use the path, delimited by forward slashes ('/'), to place the menu item within a submenu. |
Action<DropdownMenuAction> | actionCallback | Action to be executed when the menu item is selected. |
Func<DropdownMenuAction, DropdownMenuAction.Status> | actionStatusCallback | Function called to determine if the menu item is enabled. |
Object | userData | An object that will be stored in the userData property. |
Properties
eventInfo
Provides information on the event that triggered the drop-down menu.
Declaration
public DropdownMenuEventInfo eventInfo { get; }
Property Value
Type | Description |
---|---|
DropdownMenuEventInfo |
name
The name of the item. The name can be prefixed by its submenu path. Path components are delimited by forward slashes ('/').
Declaration
public string name { get; }
Property Value
Type | Description |
---|---|
String |
status
The status of the item.
Declaration
public DropdownMenuAction.Status status { get; }
Property Value
Type | Description |
---|---|
DropdownMenuAction.Status |
userData
The userData object stored by the constructor.
Declaration
public object userData { get; }
Property Value
Type | Description |
---|---|
Object |
Methods
AlwaysDisabled(DropdownMenuAction)
Status callback that always returns Status.Disabled.
Declaration
public static DropdownMenuAction.Status AlwaysDisabled(DropdownMenuAction a)
Parameters
Type | Name | Description |
---|---|---|
DropdownMenuAction | a | Unused parameter. |
Returns
Type | Description |
---|---|
DropdownMenuAction.Status | Always return Status.Disabled. |
AlwaysEnabled(DropdownMenuAction)
Status callback that always returns Status.Enabled.
Declaration
public static DropdownMenuAction.Status AlwaysEnabled(DropdownMenuAction a)
Parameters
Type | Name | Description |
---|---|---|
DropdownMenuAction | a | Unused parameter. |
Returns
Type | Description |
---|---|
DropdownMenuAction.Status | Always return Status.Enabled. |
Execute()
Execute the callback associated with this item.
Declaration
public void Execute()
UpdateActionStatus(DropdownMenuEventInfo)
Update the status flag of this item by calling the item status callback.
Declaration
public void UpdateActionStatus(DropdownMenuEventInfo eventInfo)
Parameters
Type | Name | Description |
---|---|---|
DropdownMenuEventInfo | eventInfo | Information about the event that triggered the display of the drop-down menu, such as the mouse position or the key pressed. |