Skip to content

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.

{
  "menuItemIds": ["my-search"],
  "context": "..."
}
{
  "states": "..."
}

JSON Schemas: Request ยท Response