GetMenuItemState¶
Query dynamic enabled/disabled/checked state of menu items.
When is this called?
Called before showing a menu containing plugin items.
C# Override¶
public override GetMenuItemStateResponse? GetMenuItemState(
GetMenuItemStateRequest request)
{
bool hasProject = request.Context.ProjectPath != null;
return new GetMenuItemStateResponse
{
States = new Dictionary<string, MenuItemState>
{
["my-search"] = new() { Enabled = hasProject },
}
};
}
Request¶
| Field | Type | Required | Description |
|---|---|---|---|
menuItemIds |
array<string> |
โ | Menu item IDs to query. |
context |
PluginContext |
โ | Current host application state. |
Response¶
| Field | Type | Required | Description |
|---|---|---|---|
states |
map<string, MenuItemState> |
โ | Map of menu item ID to state. |
JSON¶
The SDK serializes these JSON bodies for you.